Last active
June 8, 2025 00:36
-
-
Save brunopk/ef6eb3cb3a4696d1ba57bfd3375318f7 to your computer and use it in GitHub Desktop.
Homa Assistant
- To find event names :
- Go to https://your-homeassistant-address/developer-tools/event (Developer tools > Events)
- Write "*" under "Listen to events"
- Click in "Start listening"
- Fire the event (for instance turning a button on)
- Create a helper with "Input button" type.
- Add a Button card to a dashboard:
- show_name: true show_icon: false type: custom:button-card name: '#0000FF' entity: input_button.sc_button_blue show_state: false color_type: card icon: '' styles: card: - background: rgb(0, 0, 255) - color: white tap_action: action: perform-action perform_action: input_button.press target: entity_id: input_button.sc_button_blue
- Create the AppDaemon application :
- Define application in configuration file (usually in
addon_configs/a0d7b954_appdaemon/apps/apps.yaml
) :app_name: module: module_name class: YourApp button_id: input_button.sc_button_blue
- Add the Python code into
addon_configs/a0d7b954_appdaemon/apps/module_name
(the module name is defined in AppDaemon configuration YAML): -
import appdaemon.plugins.hass.hassapi as hass class ScApp(hass.Hass): """AppDaemon application to interact with SC RPI.""" def initialize(self) -> None: """Initialize configurations.""" entity_id = self.args["button_id"] state = self.get_state(entity_id, attribute="all") if state is not None: actual_state = state["state"] attributes = state["attributes"] self.log(f"State: {actual_state}") self.log(f"Attributes: {attributes}") self.listen_event( self.button_pressed_handler, "state_changed", entity_id=entity_id, ) else: self.log(f"get_state returned None for {entity_id}") def button_pressed_handler( self, event_name: str, data: dict[str, Any], **_kwargs: Any ) -> None: """Button press event handler.""" self.log(f"Button event received event {event_name} and data {data}")
- Define application in configuration file (usually in
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment