Replies: 2 comments
-
@DanielWinks Could you help here? |
Beta Was this translation helpful? Give feedback.
-
Hi @rikdc I've got quite a number of devices with double tap, triple tap, etc. I've got a few Hank 4-button/8-scene controllers, too. By far, the slickest and nicest way to integration all of these "buttons" into Home Assistant is with MQTT Device Triggers. This gives actual "buttons" in Home Assistant that can be used for triggering automations, such as these: 1, 2, 3, 4. Presently, in order to use these we need to manually create the MQTT Discovery Payloads for them, and you need to change the settings in ZwaveJS2MQTT from the default "time-value" to "value only" for it to work. The reason for this is that the MQTT Device Trigger in Home Assistant expects a plain string payload and cannot work with templates/JSON. Once that's changed, you'll need to redo all the discovery in Zjs2MQTT. If you have retained discovery on, you may need to use MQTT Explorer to delete all the retained messages. Then open up each device in Zjs2MQTT (after changing to "value only"), and click on "Rediscover Node" and then "Store" to permanently store all the payloads. Next, you'll need to make a few more objects here, making sure to match the exact "device" that's already being used, so Home Assistant properly assigns all the new entities you'll create to the existing device, such as a switch, scene controller, etc. Here's a sample of the generated JSON from Zjs2MQTT{
"type": "light",
"object_id": "dimmer",
"discovery_payload": {
"command_topic": "z2m/family_room_dimmer/38/0/targetValue/set",
"state_topic": "z2m/family_room_dimmer/38/0/currentValue",
"state_value_template": "{{ \"OFF\" if value == 0 else \"ON\" }}",
"brightness_command_topic": "z2m/family_room_dimmer/38/0/targetValue/set",
"brightness_scale": 99,
"brightness_state_topic": "z2m/family_room_dimmer/38/0/currentValue",
"brightness_value_template": "{{ value }}",
"on_command_type": "brightness",
"device": {
"identifiers": [
"zwavejs2mqtt_0xebd8bb21_node2"
],
"manufacturer": "Inovelli",
"model": "Red Series Dimmer (LZW31-SN)",
"name": "family_room_dimmer",
"sw_version": "1.52"
},
"name": "family_room_dimmer_dimmer",
"unique_id": "zwavejs2mqtt_0xebd8bb21_2-38-0-currentValue"
},
"discoveryTopic": "light/family_room_dimmer/dimmer/config",
"values": [
"38-0-currentValue",
"38-0-targetValue"
],
"persistent": false,
"ignoreDiscovery": false,
"id": "light_dimmer"
}
So, based on this, we'll create a device trigger for each button. I'll use the "config button" on my Inovelli Dimmer as an example. Config Button JSON for Inovelli Dimmer{
"type": "device_trigger",
"object_id": "config_button_pressed",
"discovery_payload": {
"payload": "0",
"type": "button_short_press",
"subtype": "Config Button",
"topic": "z2m/family_room_dimmer/91/0/scene/003",
"automation_type": "trigger",
"device": {
"identifiers": [
"zwavejs2mqtt_0xebd8bb21_node2"
],
"manufacturer": "Inovelli",
"model": "Red Series Dimmer (LZW31-SN)",
"name": "family_room_dimmer",
"sw_version": "1.52"
},
"name": "family_room_dimmer_dimmer",
"unique_id": "zwavejs2mqtt_0xebd8bb21_2-91-0-scene-003"
},
"discoveryTopic": "device_automation/family_room_dimmer/config_button_pressed/config",
"values": [
"91-0-scene-003"
],
"persistent": true,
"ignoreDiscovery": false,
"id": "device_trigger_config_button_pressed"
} I recommend using something like VS Code to create the JSON, and saving the ones you make in a folder somewhere, too, just in case you need to use them again. Once you have JSON created for the "Hass Device JSON" in Zjs2MQTT, you can add each object to the node, by going to the Home Assistant tab, pasting it on the right hand side, clicking on "ADD", then "STORE" on the left. It's a bit of a pain for sure, and hopefully further work between developers here and Home Assistant can get these "device trigger" payloads to be auto-generated like they are for the dimmer, power sensors, and other stuff. The main reason they're not auto-generated is because there's some devices that don't work right with "only value" payloads, so the default (from back in Zwave2MQTT days, too) has always been "time-value" JSON. I personally don't have any devices which don't work properly with "just value", so this is fine for me. I'm not even sure what might have an issue with it, maybe garage door openers or something else I don't actually own any devices of that type. And since the default payload is "time-value", then Zjs2MQTT can't auto-generate "device trigger" entities in HASS because those simply cannot work with JSON. So to get this to be a bit less of a manual process, like I detailed above, both HA needs to rework the MQTT Device Trigger integration to allow for JSON payloads and allow using templates in the payload config for processing JSON, and also adding the auto-generated "device triggers" in Zjs2MQTT to use that. Or at the very least, auto-generate them when clicking on "Rediscover Node" in Zjs2MQTT while the payload type is set to "value only". But until then, you can have them in HA, just with a bit of work. Personally, I just wrote a Python script that actually generates all of my discovery payloads, and use that instead of discovery in Zjs2MQTT, but that's even more work to do than what I described above, and probably only worthwhile if you're also using it to "device-ifiy" other MQTT things, such as MQTT devices coming in from rtl_433. |
Beta Was this translation helpful? Give feedback.
-
I have a Zen34 scene controller and trying to figure out how to integrate it with Home-Assistant with MQTT. I've seen some state updates, but also wondered if the _EVENTS topic will be more stable. I'm confused on how these are meant to be integrated. Is there any relevant documentation available?
Update:
I first created a sensor that listened to the MQTT event. Automations would trigger with template conditions:
Although this worked, it was slow and doesn't scale. I've now created an automation that listens to the change, and triggers internal events.
And then subsequent automatons can be triggered by the event.
Beta Was this translation helpful? Give feedback.
All reactions