Home Assistant interpretation of ramp to zero?

Discussion in 'Third-Party Solutions' started by SgrAystar, Jul 18, 2023.

  1. SgrAystar

    SgrAystar

    Joined:
    Oct 4, 2018
    Messages:
    60
    Likes Received:
    5
    Location:
    Melbourne, Australia
    Have any HA users encountered this scenario?

    I decided to try out HA and have installed the cbus2mqtt add-on that uses cmqttd and run with default HA MQTT Discovery.
    All C-Bus light GA’s appear in HA and all is good, until ...

    The question comes about when a GA is already off, then ramped to OFF again within C-Bus, e.g. in a Goodbye Scene.
    All lights in the scene then turn on in HA...

    Using MQTT Explorer you can see that when C-Bus issues the command ramp to zero it results in cmqttd updating "homeassistant/light/cbus_10/state" with "{"state": "ON", "brightness": 0, "transition": 8, "cbus_source_addr": 54}"
    In HA this changes the light to ON, at the previous retain level.
    There is no cmqttd update to ".../set" and the binary sensor in HA stays OFF.

    Since this has been around for a while I wondered how other people handled it.
    Maybe it has something to do with the default HA Discovery and I should try a lights.yaml configuration?
     
    SgrAystar, Jul 18, 2023
    #1
  2. SgrAystar

    SgrAystar

    Joined:
    Oct 4, 2018
    Messages:
    60
    Likes Received:
    5
    Location:
    Melbourne, Australia
    Never mind, appears to be a bug in libcbus.
     
    SgrAystar, Jul 19, 2023
    #2
  3. SgrAystar

    Ingo

    Joined:
    Dec 2, 2006
    Messages:
    290
    Likes Received:
    1
    Location:
    South Africa
    I run cbus2mqtt in a docker and I did the following to send the correct state value:

    1. Enter the docker shell ("docker exec -it $(docker ps -f name=cbus2mqtt -q) bash") and edit cmqttd.py.
    2. Find and edit the function below and change values in bold.

    def lighting_group_ramp(self, source_addr: Optional[int], group_addr: int, duration: int, level: int):
    """Relays a lighting-ramp event from CBus to MQTT."""
    state = 'ON if level > 0 else 'OFF'
    self.publish(state_topic(group_addr), {
    'state': state,
    'brightness': level,
    'transition': duration,
    'cbus_source_addr': source_addr,​
    })
    self.publish_binary_sensor(group_addr, level > 0)​
     
    Ingo, Jul 19, 2023
    #3
    SgrAystar likes this.
  4. SgrAystar

    SgrAystar

    Joined:
    Oct 4, 2018
    Messages:
    60
    Likes Received:
    5
    Location:
    Melbourne, Australia
    Thanks @Ingo that will fix it.
     
    SgrAystar, Jul 20, 2023
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.