WTH I cannot easily sync entity attributes (ZB dimmmer switch + wifi ceiling fan)

I have a few rooms that have an Inovelli Blue switch with a Big A** Fan. Because the Big A** Fan is not Zigbee, I can’t rely on binding.

The Inovelli Blue switch light.room_switch exposes a brightness attribute, and also, the Big A** Fan’s light module light.fan_light exposes a brightness attribute.

One-way syncing would be easy enough, but the fan also has an IR remote which I can use to adjust its brightness.

So, overall, what I want is an easy way to tell Home Assistant, “Keep the brightness of these two entities synced. If the switch brightness updates, then update the fan brightness. If the fan brightness updates, then update the switch brightness.”

I’ve tried various blueprints to try and achieve this and they are all pretty clumsy. I’ve even tried to make my own automation, and it’s not perfect either.

My attempt:

alias: Office Light Test
description: ""
triggers:
  - trigger: state
    entity_id:
      - light.office_switch
    attribute: brightness
    id: switch
  - trigger: state
    entity_id:
      - light.fan_light
    id: fan
conditions:
  - condition: state
    entity_id: input_boolean.sync_lock
    state: "off"
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - switch
        sequence:
          - sequence:
              - action: input_boolean.turn_on
                metadata: {}
                data: {}
                target:
                  entity_id: input_boolean.sync_lock
              - action: light.turn_on
                metadata: {}
                data:
                  brightness: >-
                    {{ state_attr('light.office_switch', 'brightness') if
                    state_attr('light.office_switch', 'brightness') is
                    not none else 0 | int }}
                target:
                  device_id: 80d01acc2e8797bd69915c442d4cf682
      - conditions:
          - condition: trigger
            id:
              - fan
        sequence:
          - sequence:
              - action: input_boolean.turn_on
                metadata: {}
                data: {}
                target:
                  entity_id: input_boolean.sync_lock
              - action: light.turn_on
                metadata: {}
                data:
                  brightness: >-
                    {{ state_attr('light.fan_light', 'brightness') if
                    state_attr('light.fan_light', 'brightness') is not
                    none else 0 | int }}
                target:
                  device_id: 40ac60861a4e345b16b7970ed8d29c07
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
    enabled: true
  - action: input_boolean.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: input_boolean.sync_lock
mode: parallel

Sometimes the sync_lock get’s in a weird state if we have a power flicker or something and I accidentally press the wall switch while some comms are down. The whole idea behind the sync lock is to prevent a looping condition whereby Home Assistant sees the fan light brightness change, so it updates the switch brightness, but then it sees the switch brightness change, so it updates the fan brightness, and so on.

Instead of a sync lock, you could just change the automation mode to single. That way the event fired when the automation changes the brightness would not be able to trigger the automation to run again. You could keep the short delay at the end of the automation to ensure that it is still running as the event is processed (I don’t happen to know if events and the things they trigger are processed synchronously or not).

It was originally in single mode. I forget why I changed it to parallel, but I do remember some strange behavior. I’ll see if I can get some time to switch it back tonight and report what happens.

Regardless, this seems like it would be a really good QoL improvement if Home Assistant exposed an attribute sync mechanism.

Essentially a Home Assistant version of Zigbee bindings that can span communication protocols. I like it.

1 Like

Single mode might not always work.
Best way is to make a check in the beginning to see if the value is already correct and abort if it is.
This should stop the looping as long as you do absolute values and not relative ones.