Set Brightness Of Shelly Dimmer to XX% but not necessarily turn light on

Hello,
I’ve got a handful of shelly dimmers throughout the house and would like to have a button on my dashboard to set the brightness of all the dimmers (whether they are on or off) to a certain percentage.

I figured I could do this through a rest_command like so.

rest_command:
shelly_dimmers20_percent:
url: “http://172.16.19.20/light/0/?brightness=20

And it did work as I could execute that through a script. But when added in the other URLs of the lights it didn’t like the syntax.

rest_command:
shelly_dimmers20_percent:
url: “http://172.16.19.20/light/0/?brightness=20
url: “http://172.16.19.21/light/0/?brightness=20
url: “http://172.16.19.22/light/0/?brightness=20
url: “http://172.16.19.23/light/0/?brightness=20
url: “http://172.16.19.24/light/0/?brightness=20
url: “http://172.16.19.25/light/0/?brightness=20
url: “http://172.16.19.26/light/0/?brightness=20

Is there a way to accomplish what I am trying to do through a single rest command? or perhaps there is a more elegant way?

Regards,
Peter

Why are you using rest instead of the usual HA settings?

Why do you want to set the brightness of a light that is off?

I’m just trying to figure out the best way to do it. Didn’t know there was a better way?

Because lets say it reaches 8pm, I want to set all the lights brightness to 20% (even the off ones). That way when I turn the lights on (for example the bedroom, bathroom) they are already at the pre-set level.

I have been able to create a group of devices in HA and then configure a light card on the dashboard that lets me set the brightness to X level. The only problem is it will turn on all lights that are off.

Hah!

I was just composing a topic just like this and the forum threw this thread up before I posted:

What I was going to say (in part):

I know that is it technically possible in some way because in the Shelly apps you are able to move the brightness slider independently of turning the lights on - so when you move the slider it is sending a command to the device to set the desired brightness so next time you do turn the lights on there are already at the desired level.

If anyone still cares, here’s how I use it:

rest_command:
  shelly_helligkeit:
    url: "http://{{ ip }}/light/0?brightness={{ helligkeit }}"

Then I only need to use the service call wherever I need it:

service: rest_command.shelly_helligkeit
data:
  ip: 192.168.178.74
  helligkeit: 20
5 Likes

Thanks - i will try this - it seems like such an obvious requirement.

Thanks for sharing - better than I was hoping for. I was about to do each dimmer as a separate entry. Thanks Again

Thanks for this. How are you getting the IP addresses? Just manually? I can’t find a way to programatically get the IP address of Shelly devices. Want to set it up in a bunch of automations that runs through a list of devices.

I only have 5 devices I need to controll via REST, so I type the adresses manually. My other 20 devices I controll via the integration only.
The IP of a device can be found in the attributes of the corresponding device tracker entity (if you have a network monitoring integration). But how to automatically do this connection - I don’t know.

yep ok thanks! That’s helpful. Annoying as the data is obv in HA since they have the link but can’t get it out!

Use the hostname, let DNS get the ip address.

sorry hostname for what? The shellys don’t have a hostname as far as I’m aware on the local network? Am I missing something? If there’s a way for me to get to the shellys REST via hostname, I’d love to know how that would work. Also not sure how I’d get the hostname from within a HA automation?
Thanks!

Yes they do, for example one of mine is shellyuni-C45BBE6BDEA9

thanks - that still doesn’t help me as that name isn’t available in home assistant through any of the attributes so I cannot access it programmatically. Still requires me to get the hostnames and map to entity_id within HA.

If you have to many shelly devices to hard code the ip addresses or hostnames, you could try a customize entry eg

  customize:
    light.dining_table_lights:
      hostname: shellyuni-C45BBE6BDEA9
      ip: 192.168.25.25

You won’t need both :slight_smile:

Awesome thank you. That’s what I need!

My router is integrated into Home Assistant, and that integration can be used to get the IP address from the Shelly’s entity ID.

service: rest_command.shelly_brightness
data:
  ip: "{{ state_attr('device_tracker.shellydimmer2_c45bbe5707e1', 'ip') }}"
  brightness: 20
3 Likes