CBUS device state not being retained

Hi Everyone,

I have implemented CBUS integration with the SHAC module talking to Home Assistant via MQTT. I followed the great documentation provided by others to get this setup. It works brilliantly and I can control any CBUS device (lights, switches, sensors etc).

My only issue is that the state of the device doesnt seem to get remembered by Home Assistant. So if I switch a light on, the Home Assistant UI seems to forget that this ever happened and toggles the switch back off about 3 seconds later. So if I’m scanning to see which lights are currently on in the house, I can’t easily tell.

Weirdly, this doesn’t happen to all lights. I have two different types of lights

  1. LED strips (these mainly seem to track the state)

and

  1. Regular LED lights (these dont track state).

My configuration for both is the same.

    - name: 'Sofia Room DLs'
      state_topic: 'cbus/read/254/56/51/state'
      command_topic: 'cbus/write/254/56/51/switch'
      brightness_state_topic: 'cbus/read/254/56/90/51/level'
      brightness_command_topic: 'cbus/write/254/56/51/ramp'
#      payload_on: 'ON'
      payload_off: 'OFF'
      on_command_type: 'brightness'
      unique_id: 'mqtt_sofia_room_dl'
#      brightness_scale: '100'
    - name: 'Sofia Room Window'
      state_topic: 'cbus/read/254/95/3/state'
      command_topic: 'cbus/write/254/95/3/switch'
      brightness_state_topic: 'cbus/read/254/95/3/level'
      brightness_command_topic: 'cbus/write/254/95/3/ramp'
#      payload_on: 'ON'
      payload_off: 'OFF'
      on_command_type: 'brightness'
      unique_id: 'mqtt_sofia_room_win'
#      brightness_scale: '100'

Does anyone have any advice on why state isn’t being kept or what I’m doing wrong? Thank you in advance and thankyou to AutoSteve and all the others that wrote the CBUS/MQTT scripts!

Hello jcmasters,

I think when it does this it is not getting the feedback from the device that it likes to know if it’s on or off. For instance all my rf433 switches tend to do this and those there is no feedback possible. thet run in assumed mode.

Thank you for the reply.

Its possible that as the device isnt being polled/monitored directly (only through MQTT) that it can’t detect a state. However, id love an option to keep the last known state (you referred to it as assumed mode). It wouldn’t be perfect but would be better then what I have.

I wasn’t sure if these were switches or lights, but look here:

Thank you. Much appreciated.

For anyone who is interested, I fixed this by setting the value

optimistic: true

This changed my light toggle button from a switch to separate on/off icons. However it was a small price to pay to have the state retention.