GithubHelp home page GithubHelp logo

MQTT function about zigate HOT 12 CLOSED

doudz avatar doudz commented on September 23, 2024
MQTT function

from zigate.

Comments (12)

doudz avatar doudz commented on September 23, 2024 1
sensor:
  - platform: mqtt
    state_topic: "zigate/attribute_changed/21d3/01/0402/0000"
    name: 'Temperature'
    unit_of_measurement: "°C"
    value_template: '{{ value_json.value }}'

This is a Xiaomi temperature sensor, addr 21d3, endpoint 01, cluster 0x0402, attribute 0x0000
I agree it's not really user friendly, but it works

from zigate.

doudz avatar doudz commented on September 23, 2024

Currently I use it with Home Assistant

from zigate.

Emmegiemme avatar Emmegiemme commented on September 23, 2024

Cool, I will try to use it with mosquitto on OpenHab

from zigate.

doudz avatar doudz commented on September 23, 2024

Closing since no update

from zigate.

pdecat avatar pdecat commented on September 23, 2024

Hi @doudz, since you said you were doing it, I'm trying to integrate my ZiGate (plugged with USB-TTL module) with Home Assistant using your MQTT broker implementation as it certainly is the most elegant way to do it.

However I'm currently struggling figuring out the proper configuration.

Is device discovery supposed to work with Home Assistant's MQTT discovery?

Are the topics for discovery, command and state supposed to match out of the box?
Or is customization needed?

Here what I've tried right now but I doubt this would ever work as Home Assistant expects the discovery topic to follow the <discovery_prefix>/<component>/[<node_id>/]<object_id>/<> format:

mqtt:
  discovery: true
  discovery_prefix: zigate/device_changed

light:
  - platform: mqtt
    command_topic: "zigate/command"

Also, I guess state_value_template are needed to extract values from messages as described at https://www.home-assistant.io/components/light.mqtt/

Would you mind sharing an example Home Assistant configuration snippet for your MQTT broker?

from zigate.

pdecat avatar pdecat commented on September 23, 2024

Hmm, I just stumbled on https://github.com/Koenkk/zigbee2mqtt and https://github.com/danielwelch/hassio-zigbee2mqtt

from zigate.

doudz avatar doudz commented on September 23, 2024

Oh... That's what I was looking for before buying a zigate...

from zigate.

doudz avatar doudz commented on September 23, 2024

Currently my mqtt broker doesn't support discovery.
I'll send you a example of what I use on my system soon

from zigate.

pdecat avatar pdecat commented on September 23, 2024

Thanks, that helped!

FWIW, here is the best I have managed to achieve so far with the MQTT Template Light platform to control my IKEA Tradfri Lights (on/off and level control working):

light:
  - platform: mqtt_template
    command_topic: "zigate/command"
    command_on_template: >
      {%- if brightness is defined -%}
      {"function": "action_move_level_onoff", "args": ["5c2f", 1, 1, {{ brightness / 255 * 100 }}]}
      {%- else -%}
      {"function": "action_onoff", "args": ["5c2f", 1, 1]}
      {%- endif -%}
    command_off_template: '{"function": "action_onoff", "args": ["5c2f", 1, 0]}'
    optimistic: true
    brightness_template: '' # Not None to allow controlling brightness
    state_topic: "zigate/attribute_changed/5c2f/01/0006/0000"
    state_template: '{{ value_json["value"] }}'

This still misses light level state changes and initial device state messages pushed to zigate/device_changed/5c2f.

Now, none of the current MQTT light platforms is gathering all required features to allow for a perfect fit:

  • light.mqtt is missing command templates features to be able to format command messages as JSON
  • light.mqtt_template is missing a brightness_state_topic option to process zigate/attribute_changed/5c2f/01/0008/0000 messages.
  • light.mqtt_json is missing command templates and a brightness_state_topic option to process zigate/attribute_changed/5c2f/01/0008/0000 messages.

At this point, I'm considering to adapt your project (what's the license by the way?) to send all device and attribute change events to the same topic and use the mqtt.light_template platform with some configuration like the following:

light:
  - platform: mqtt_template
    command_topic: "zigate/command"
    command_on_template: >
      {%- if brightness is defined -%}
      {"function": "action_move_level_onoff", "args": ["5c2f", 1, 1, {{ brightness / 255 * 100 }}]}
      {%- else -%}
      {"function": "action_onoff", "args": ["5c2f", 1, 1]}
      {%- endif -%}
    command_off_template: '{"function": "action_onoff", "args": ["5c2f", 1, 0]}'
    state_topic: "zigate/device_changed/5c2f"
    state_template: '{{ value_json["endpoints"][0]["clusters"][0]["attributes"]["value"] }}'
    brightness_template: '{{ value_json["endpoints"][0]["clusters"][1]["attributes"]["value"] }}'

from zigate.

doudz avatar doudz commented on September 23, 2024

Yes I agree, I think there's no other way .
About the licence, I have no choose right now, but the MIT licence is probably the best choice

from zigate.

lolorc avatar lolorc commented on September 23, 2024

Oh... That's what I was looking for before buying a zigate...

@doudz quite off-topic, but why did you choose a zigate instead ?
I'm owning one and I've just bought stuff to try to replace it by zigbee2mqtt.

from zigate.

qm3ster avatar qm3ster commented on September 23, 2024

@lolorc what was your problem with ZiGate?

from zigate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.