Slide switches

I have some switches setup in HA that work perfectly fine. but they are using the “lightning” on and off buttons, how do I make them use the slide switches as I think they look better???

Many Thanks
Lee

You mean to be able to dim a light without bringing up an info panel? You could set up an input_slider component with a range between 0 to 255. You simply set up something in automation section:

[code]input_slider:
slider_switch1
name: “Switch1”
initial: 0
min: 0
max: 255
step: 1

automation:

  • alias: “LR FL Dimmer”
    trigger:
    platform: state
    entity_id: input_slider.input_lr_fl_bri
    action:
    service: shell_command.switch1_dimmer[/code]

…which calls the script:

shell_command: switch1_dimmer: ~/shell_script/switch1_dimmer

And here’s the heart of the script:

#!/bin/bash SWITCH1_BRI=$(curl -X GET http://localhost:8123/api/states/input_slider.slider_switch1 2> /dev/null | \ tail -n2 | head -n1 | awk '{print $2}' | sed -e 's/"//g' ) -X POST http://localhost:8123/api/states/light.switch1 -d '{"state": "on", "attributes": {"brightness": '$SWITCH1_BRI', "transition": 1}}'

However, it does not look like it will work. I tried executing a statement to set the brightness of a light:

curl -X POST http://localhost:8123/api/states/light.bedroom_lamp_l -d '{"state": "on", "attributes": {"brightness": 100, "transition": 1}}'

It simply returned a result:

{ "attributes": { "brightness": 100, "transition": 1 }, "entity_id": "light.bedroom_lamp_l", "last_changed": "22:31:53 14-04-2016", "last_updated": "22:31:53 14-04-2016", "state": "on" }

And it did nothing.

But even if it did, every time you restart Home Assistant, the state of the brightness for input_slider.slider_switch1 won’t be saved.

So at any rate, it does not seem possible to change the switch into a slider.

Hi!

I think @grooml means the two buttons that are shown if an entity has assumed state set to true. If assumed state is set to false, a slider button for on/off will show instead.

Depending on the type of device, it might be possible to change a config option to make the entity not show as to have an assumed state. For MQTT and MySensors this option is called “optimistic” in the config. See for example:

1 Like

Martin is correct, I think its down to the assumed state thing…If I remove the persistence line in the conf the switches turn into slide switches but they don’t work.(i.e. they will not slide to the on position) ill have another bash tonight…