If I have correctly understood openHAB’s light configuration, it controls the light exclusively using a value between 0 and 100, inclusively. In other words, it doesn’t need to use commands like ON
or OFF
to control the light, just brightness levels.
I believe the equivalent in Home Assistant is this:
light:
- name: My Dimmer
state_topic: oh3/dimmer/my_dimmer/state_bright
state_value_template: "{{ 'ON' if value | int(0) > 0 else 'OFF' }}"
command_topic: oh3/dimmer/my_dimmer/cmd
brightness_state_topic: oh3/dimmer/my_dimmer/state_bright
brightness_command_topic: oh3/dimmer/my_dimmer/cmd_bright
brightness_scale: 100
on_command_type: brightness
on_command_type
is set to brightness
to indicate to Home Assistant that the physical light only needs brightness values to control it.
state_topic
is set to the same topic as brightness_state_topic
. However, state_value_template
is also employed to convert a received integer value to ON
or OFF
(which are the default values Home Assistant uses for interpreting the physical device’s current state).
NOTE
This line in the configuration probably doesn’t do anything to control your physical lights. However, we can’t remove it because, according to the documentation, command_topic
is a required option.
command_topic: oh3/dimmer/my_dimmer/cmd
I suspect Home Assistant may not publish anything to that topic when on_command_type
is set to brightness
. I suggest using an MQTT client to monitor the topic just to confirm if Home Assistant does/doesn’t publish anything to it.