I recently installed a Shelly 1 behind one of my light switches and it works like a charm with a normal lightbulb.
Via MQTT I can now switch the relay to turn on or turn off the light independently of the state of the (wall)switch.
But what I would like to achieve is to use the shelly in combination with a smart bulb.
With the current configuration it switches off the power like a normal switch does and therefore the smartbulb loses its connection with (in my case) the tradfri hub.
When I change the button type in the Shelly interface to “ Detached Switch – switch is separated from the relays” it does not affect the relay, but I can’t seem to find a way to read the state of the switch to make a automation for example.
Does someone have experience with setting up the Shelly1 like the way i would like to use it? Or does someone have any tips?
It’s very easy. You have to change button type to detached switch and power on default mode to on in Shelly configuration.
In HA you have to move your smart bulb entity to the frontend (to turn on/of the light manually) and add automation:
Thanks for your response. But I think your solution works via a MQTT sensor. I found a state topic called “shellies/shelly1-******/input/0” which I configured as a template sensor.
When I physically flip the switch the state of the sensor changes from 0 to 1 but unfortunately the state changes with some delay.
Sometimes it will take up to 20 seconds before the state changes. And i want the lightbulb to switch on almost directly and the same goes for the light to switch off.
Does your solution work the same way?
Some want to have light bulbs which are dimmable and can change color/hue. That way you can have a physical switch and the benefit of “smart” bulbs.
I installed your solution, but unfortunately it does not work all the time. Sometimes the binary sensor changes after 10 seconds, or not at all. And it’s weird because the relay switch works immediately but that’s the one i don’t want to use
It’s because i want to use the original phyiscal lightswitch but still be able to change brightness of the smartbulb. And i don’t want the smartbulb losing connection with the hub. If the bulb will not connect it will create errors in the zigbee network in my usecase.
Thanks to your post I understand finally the binary sensors
I tried to configure the same as you but for some reasons the phisical switches don’t work.
Can you tell me how to check what is wrong? Could the reason be that I 3 switches attached to my shelly 1?
Here are my configuration files:
binary_sensor.yaml ( I had already all my Shellies configured so I added this manually )
You can do cool things with a shelly switch. I’m using a counter to count the times a wall-switch is turned over. And based on that number do some action.
And the actions. Maybe it can be done in one automation, but this works
- alias: Turn on eetafel when counter is 1
hide_entity: true
trigger:
platform: state
entity_id: counter.eettafel
to: "1"
for:
milliseconds: 250
action:
- service: light.toggle
data_template:
entity_id: >
{% if now().hour >= 6 %} light.eettafel
{% elif now().hour >= 0 and now().hour < 6 %} light.lampjes_langs_plafond
{% endif %}
- service: counter.reset
entity_id: counter.eettafel
id: turn_on_eettafel_light_when_counter_is_1
- alias: Control Lights With Switch Eettafel
hide_entity: true
trigger:
platform: numeric_state
entity_id: counter.eettafel
above: 1
for:
milliseconds: 250
action:
- service: scene.turn_on
data_template:
entity_id: >
{% if states('counter.eettafel') | int == 2 %} scene.woonkamer_uit
{% elif states('counter.eettafel') | int > 2 and ( now().hour >= 12 or now().hour < 6 ) %} scene.woonkamer_lezen
{% elif states('counter.eettafel') | int > 2 and now().hour < 12 and now().hour >= 6 %} scene.woonkamer_energie
{% endif %}
- service: counter.reset
entity_id: counter.eettafel
id: control_lights_with_switch_eettafel
By turning the wall-switch one time, it just turns of the light connected to the wall-switch. If it is turned over more times within 250ms (this is fast enough on my NUC) it does some other stuff. Best part is turning the wall-switch over two times to turn everything of at the end of the day.
The last action of resetting the coutner is very important. Otherwise it will only work once.
Nope… it’s not working anyway.
If you confirm me all is correct, then it means that you can’t use 3 switch configuration when detached option is activated.
I finally understand why it wasn’t working.
Don’t know why but if I restart hass and the relay where you have the smartbulb (yeelight) isn’t on hass reboot, it cancel the smartbulb entity even if it’s manually configured.
Turning back on the topic…
3 Way Wallswitch configuration works, but sometimes I’m missing some switching and actually can’t understand what is causing it. Did also a check on the MQTT traffic and some input 0 came up without pressing.
After a few days of testing I can confirm that if the Shelly is set on detached mode and you have more than one wall switch connected to it you can’t use the input state for a sensor.
That’s why even if you switch on one of them, another swaps back the state to its position causing the change of the state.
I’ve got one smart bulb on a shelly with 3 way configuration and another on a 4 way. Should the input state be different to each switch you could set an automation that considers the toggling of one of them and reuse it for turning the smart bulb entity on but in this case I guess it’s quite impossible.
So unless someone denies what I’m writing I give up on this… Thank you anyway… I learned a lot these days.