Zwave rotary dimmer as volume control to media player. eg soundbar

I have an zwave rotary dimmer i used for volume purposes in OH, after swithing to HA I have had trouble getting an automation to work with this

the brigtness goes from 0-255
the volume on the soundbar goes from 0-1 where ex 0.20 is 20%

anyone have a pointer how to achieve this?


Something like this in an automation

alias: change the soundbar vol
description: ""
  - platform: state
      - light.kitchen_dimmer
    attribute: brightness
condition: []
  - service: media_player.volume_set
      volume_level: "{{(state_attr('light.kitchen_dimmer','brightness'))/255}}"
      entity_id: media_player.soundbar
mode: single
1 Like

Thanks, works perfectly

Still do not understand HOW or why HA converts the state eg 220 on the dimmer
to a state on the soundbar 0.40 for example. Or is there a logic built in to ha

Probably historical. Someone implemented lights as having a brightness from 0 to 255. Someone implemented volume as having a range of 0.0 to 1.0. It really doesn’t matter when stuff is made so easy with templates.

1 Like