Skip to content

Easier Home Assistant Zigbee2MQTT light integration - listen to specific topic and not just state #130

Open
@htvekov

Description

@htvekov

EDIT: Updated HA example with needed mode when groups of lights are turned on/off simultanously.
EDIT: Revised setTopic for JSON example

Hi' @sieren

First of all: Great piece of software ! 👍🎉😎

I've had Homepoint in the test pipeline for quite a few months and finally I got time to test with my set up.
My initial struggle was not with Homepoint, but rather my newly bought, but semi defective, M5 stack.
Dead CP210X chip 😖, which took me half a day to realise before I finally programmed the ESP32 directly without further hazzle.

My initial impression of Homepoint - I love it ! 🤗🤗

I searched a lot, but found next to nothing regarding Z2M/MQTT Home Assistant integration - use examples/experiences etc.
So I had to move forward by trial and error 😉

It would really be helpful if users, with similar setup like me, could define a specific JSON payload key for Homepoint to read the light status (getTopic)

Example - (for type: Light as well):
Define that jsondata should be used for getTopic and the key to be used in firstKey

{
      "name": "Bed lamp",
      "setTopic": "zigbee2mqtt/Office bed lamp",
      "getTopic": "zigbee2mqtt/Office bed lamp",
      "jsondata": true,
      "firstKey": "state",
      "onValue": "ON",
      "offValue": "OFF"
      }]

Then Homepoint could read state directly from HA Z2M integrated lights via standard MQTT messages like this below:

Zigbee2MQTT:info 2021-01-04 23:57:45: MQTT publish: topic 'zigbee2mqtt/Office bed lamp', payload '{"brightness":251,"color":{"x":0.491,"y":0.39},"linkquality":105,"state":"ON","update":{"state":"idle"},"update_available":false}'

That would be awesome and much easier without the need for extra automation ! 😎

For now, I use following Home Assistant automation to push all states changes (for a list of MQTT light entities) to Homepoint on topic zigbee2mqtt/LIGHTS_FRIENDLY_NAME/get with payload state

- id: Homepoint push light state via MQTT
  alias: Homepoint push light state via MQTT
  mode: parallel # Parallel mode needed as several lights in group can be turned on/off simultanously
  trigger:
    platform: state
    entity_id:
    - light.0x680ae2fffe924460_light # Define your Z2M light entities here
    - light.0x90fd9ffffe838cb3_light # Define your Z2M light entities here
  condition:
    condition: template
    value_template: >
      {{ trigger.to_state.attributes.state !=
          trigger.from_state.attributes.state }}
  action:
  - service: mqtt.publish
    data_template:
      topic: 'zigbee2mqtt/{{trigger.to_state.attributes.friendly_name}}/get'
      payload: "{{ trigger.to_state.attributes.state }}"  

Happy New Year ! 🎉🚀

Ciao !

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions