MtSamsonite / ha-cbus2mqtt

A Home Assistant Add-on for connecting CBUS
GNU General Public License v3.0
12 stars 1 forks source link

How to feed through a change to cmqttd.py? #5

Open sgraystar opened 1 year ago

sgraystar commented 1 year ago

Thanks for the Add-on, it has made my intro to HA very straightforward.

Along the way I have found what I think is a logic bug in cmqttd.py where it does not cater for the use case of a command from C-Bus to ramp down to Off, https://github.com/micolous/cbus/issues/43

What is the chain of events to get an update though to this repository? Does it start with a change by CABrowers, followed by a change by yourself?

MtSamsonite commented 1 year ago

My apologies for the delay in response. It has been a while since I looked at this add-on. I created it for a friend using C-Bus but he has since moved to a new home which we kitted out with ZWave amongst other things. For this reason I rarely ever look at this. The PC on which I created also died (HD failure) so I am trying to recall all my steps.

I do however believe if you get an updated copy of the code from CABrowers (or alternative source) I should be able to create a new image and update the version.

If you wanted to I can also share with you how I created the image and any required files. (DM if you wish).

sgraystar commented 1 year ago

Thanks for replying. The Add-on certainly made it easy to get going, but it appears I should now learn how to create one myself.

I got as far as cloning your repositories and editing cmqttd.py then paused while other things need attention. I write linux cl a couple of times per decade so am waiting for the right frame of mind. Hopefully it 'should' be straightforward to build and push the image to docker hub. If not I will be in touch.

FYI, the fix was minor. Instead of a hardcoded "ON" state, the change in cmqttd.py was to publish an "OFF" state if the brightness level = 0.

def lighting_group_ramp(self, source_addr: Optional[int], group_addr: int, app_addr:int|Application, duration: int, level: int): """Relays a lighting-ramp event from CBus to MQTT.""" self.check_published(group_addr,app_addr)

    state = 'ON' if level > 0 else 'OFF'

    self.publish(state_topic(group_addr,app_addr), {
        'state': state,