I just acquired my first Philips Hue Tap Switch. I have connected it to HA via mqtt:
## Philips Hue Tap Switch
### Dining Room
- platform: rest
resource: http://[hue_bridge_ip]/api/[hue_bridge_user]/sensors/18
value_template: '{{ value_json.state.buttonevent }}'
name: 'Hue Tap Dining'
scan_interval: 1
- platform: rest
resource: http://[hue_bridge_ip]/api/[hue_bridge_user]/sensors/18
value_template: '{{ value_json.state.lastupdated }}'
name: 'Hue Tap Dining Last Updated'
scan_interval: 1
and then I created this automation (button 1: 34, button 2: 16, button 3: 17, button 4: 18):
###### ######
## Hue Tap Dining Automations ##
###### ######
- alias: Hue Tap Dining automations
trigger:
platform: state
entity_id: sensor.hue_tap_dining
to: "16"
action:
- service: switch.toggle
entity_id: switch.alcohol_cabinet
And it works… just as it should, but not how I want it to.
The problem: If I press button 2, the light toggles to on, but if I press button 2 again to toggle off, HA sees this as no change of state since it was already 16. I would have to press a different button to change state and then press button 2 again for the toggle off to work. The Hue Tap also has a state: lastupdated
that updates a UTC timestamp (formatted: 2017-06-17T22:22:19) to the last time a button was pressed on the Hue Tap, but I am not certain how I can implement this logic into my automation.
Has anyone else set up an automation for the Hue Tap and used a single button to toggle? I tried searching the site and web, but it seems most results are for the Hue Dimmer Switch, which works a little different.
Any suggestions would be greatly appreciated!