-
-
Notifications
You must be signed in to change notification settings - Fork 50
Create your own automations for HASPone
While the HASPone blueprints offer a lot of functionality, the real power in HASPone is making it work for your own use cases! Here we will look at some ways to leverage HASPone in Home Assistant to trigger automations in response to button presses or to send information to the HASPone device from Home Assistant.
Several MQTT messages are sent by HASPone for every button interaction. If you click on the top button of page 1 on HASPone device plate01
, the following MQTT messages will be published:
Topic | Message |
---|---|
hasp/plate01/state/p[1].b[4] | ON |
hasp/plate01/state/json | {"event_type":"button_short_press","event":"p[1].b[4]","value":"ON"} |
hasp/plate01/state/p[1].b[4] | OFF |
hasp/plate01/state/json | {"event_type":"button_short_release","event":"p[1].b[4]","value":"OFF"} |
A few things to note here:
-
p[1].b[4]
is Nextion object notation for Page 1, Button 4. See this document on how that works. - Each interaction sends a message on two different topics. One message is published to a subtopic of
hasp/<devicename>/state/<object>
with a value ofON
orOFF
, and one message under a shared subtopichasp/<devicename>/state/json
with the event data in JSON notation. You can use whichever message suits your current purpose. - One message is sent on each of those topic on button press, then another on button release
- In Home Assistant, navigate to Configuration > Automations > Add Automation, then select "Start with an Empty Automation".
- Name the automation something suitable
- Under "Triggers", select "MQTT". Set the topic to something like
hasp/plate01/state/p[1].b[4]
whereplate01
is the name of your device andp[1].b[4]
is the button you want to use as a trigger. - Enter
ON
as the payload - Configure whatever actions or conditions you'd like to complete your desired automation.
Now, pressing the assigned button on your HASPone device will trigger your custom automation!
Home Assistant Device Triggers can be created for the HASPone device using the Create Device Triggers HASPone blueprint. This approach takes some setup, but makes triggering a little more straightforward when developing your automations. Otherwise, this works the same as the MQTT approach outlined above.
- Click here to import the Create Device Triggers blueprint:
- Select your HASPone device and then provide a list of HASPone buttons which will be used for triggers. This uses the Nextion object notation for the button names, see this document on how that works.
- Click "Save", and then "Run Actions" to create the device triggers (nothing visible will happen here).
- In Home Assistant, navigate to Configuration > Automations > Add Automation, then select "Start with an Empty Automation".
- Name the automation something suitable
- Under "Triggers", select "Device" (this will be the default).
- Select your HASPone device under "Device"
- Click the pull-down next to Trigger to find a list of the buttons you defined above, one entry for each button and one each for "pressed" and "released".
- Configure whatever actions or conditions you'd like to complete your desired automation.
Now, pressing the assigned button on your HASPone device will trigger your custom automation!