Hi,
I am planning my smart stuff for my new house. I’d like to implement lots of Hue / Tradfri bulbs but have a requirement to be able to control them with light switches as well.
In order to achieve this I am thinking of the following setup
Pushbutton -> Shelly 1/2 Module -> MQTT -> HA -> Hue Bridge -> Hue Bulb
Reason for implementing a momentary switch is twofold:
looks better as the state of a regular switch does not need to represent the state of the light due to ability to control it via HA, App and lightswitch
ability to leverage multiple buttonpresses and actions associated with them.
The shelly sends a mqtt message on buttonpress for both on and off which could be used to detect the duration of the buttonpress.
See below:
shellies/shellyswitch-part of mac address of unit /input/0 1
shellies/shellyswitch-part of mac address of unit /input/0 0
I would like to use an automation to detect if the button is pressed for less than a second or more than a second to distinguish short and long presses but I am getting stuck with my automation.
Is there anybody who did this an could help out?
Blaz_Komat
(Blaž Komat)
January 27, 2019, 8:18pm
2
I have set press buttons 1 time, 2 time, 3 time and long press.
Someone in facebook shelly support have publist it
- id: '1545928456161'
alias: Stetje tipke spalnica
trigger:
- entity_id: binary_sensor.pulsante
from: 'on'
platform: state
to: 'off'
action:
- data:
entity_id: counter.spalnica
entity_id: counter.spalnica
service: counter.increment
- id: '1545928456162'
alias: spalnica dolg pritisk
trigger:
- entity_id: binary_sensor.pulsante
for:
seconds: 1
platform: state
to: 'on'
action:
- data:
entity_id: media_player.kodispalnica
service: media_player.media_next_track
- data:
entity_id: counter.spalnica
service: counter.reset
- data:
entity_id: counter.spalnica
service: counter.decrement
- id: '1545928456163'
alias: Spalnica 1 klik
trigger:
- platform: state
entity_id: counter.spalnica
from: '0'
to: '1'
for:
milliseconds: 500
action:
- service: light.toggle
data:
entity_id: light.spalnica
- service: counter.reset
entity_id: counter.spalnica
- id: '1545928456164'
alias: Spalnica 2 klika
trigger:
- platform: state
entity_id: counter.spalnica
from: '1'
to: '2'
for:
milliseconds: 500
action:
- service: light.toggle
data:
entity_id: light.spalnica_solna_luc
- service: counter.reset
entity_id: counter.spalnica
- id: '1545928456165'
alias: Spalnica 3 kliki
trigger:
- platform: numeric_state
entity_id: counter.spalnica
above: 2
for:
milliseconds: 500
action:
- service: script.turn_on
data:
entity_id: script.1545691026230
- service: counter.reset
entity_id: counter.spalnica
Also you need this in configuration
counter:
spalnica:
initial: 0
step: 1
restore: true
4 Likes
Great! This has exactly what I was looking for and more. I did not even mention multiple presses but that is also covered here.
Thanks for sharing.
RickTSD
(Rick de Jong)
October 6, 2019, 6:59pm
4
How do I figure out what / where my shelly1 is storing the binary sensor state?
Shelly does not store any data. It store it only on cloud, or send mqtt to hassio
RickTSD
(Rick de Jong)
October 7, 2019, 8:09am
6
Thanks for your fast reply :)!
I meant where do I find the MQTT requests (or so). My shelly for example sends on and off and has a name
light.kitchen_spots
the shelly itself is identified via shelly-123ABC
If I search the entities, I don’t see any button or sensor ID regarding the shelly.Thanks for your fast reply :)!
I ment where do I find the MQTT requests (or so). My shelly for example sends on and off and has a name
light.kitchen_spots
the shelly itself is identified via shelly-123ABC
If I search the entities, I don’t see any button or sensor ID regarding the shelly.
francisp
(Francis)
October 11, 2019, 8:22am
8
Use a Mqtt client like Mqtt fx, Mqtt explorer or Mqtt lens. Then you can watch the Mqtt messages
RickTSD
(Rick de Jong)
October 17, 2019, 3:57pm
9
Allright. I’ve fot MQTT Explorer running and I’ve got a relay, input en longpush (that doesn’t do anything because it’s just a normal button I guess).
What I want is the folling
Toggle once; just turn on and off the kitchen lights
Toggle twice; turn on a script / scene
On input I’ve got 1 topic, 19 messages just on / off / on / off
On input I’ve got 2 topics, 21 messages but also just on / off / on / off
There seems to be nothing for me to work with?