I’m pretty new to Home Assistant, and I want to create an on/off switch that would trigger one IFTTT action for On, and another IFTTT action when switched Off.
I’ve managed to setup a few that trigger single IFTTT actions with the ACTIVATE button/text
build a input boolean and monitor its on/off states. Input boolean is a fancy name for ‘your own on/off switch’. Build an automation that triggers off “on”, and an automation that triggers off ‘off’. That’s one way you could do it. There are so many ways you can do this. I would try that first and see how fast it is. If it’s slow, I’d investigate other ways.
input_boolean:
my_fancy_switch:
name: Fancy Switch
initial: off
automation:
- alias: turn on when fancy switch on
trigger:
- platform: state
entity_id: input_boolean.my_fancy_switch
to: 'on'
action:
- service: ifttt.trigger
data: {"event":"lounge_dimmed_50", "value1":"on"}
- alias: turn off when fancy switch off
trigger:
- platform: state
entity_id: input_boolean.my_fancy_switch
to: 'off'
action:
- service: ifttt.trigger
data: {"event":"lounge_dimmed_50", "value1":"off"}
…so now I’m trying to combine them and turn on/off 2 IFTTT triggers at once. I’ve tried lots of variations based on the existing code. Here’s an example of what I’ve tried, I’m hoping I’m along the right lines (but doesn’t work):
# Living Room Lights
- alias: Turn Living Room Lights on
trigger:
- platform: state
entity_id: input_boolean.ifttt_living_room_lights
to: 'on'
action:
- service: ifttt.trigger
data:
event: {"lounge_100", "living_room_100"}
value1: on
- alias: Turn Living Room Lights off
trigger:
- platform: state
entity_id: input_boolean.ifttt_living_room_lights
to: 'off'
action:
- service: ifttt.trigger
data:
event: {"lounge_off", "dining_room_off"}
value1: off
Any ideas on how to get this to work, turning on/off more than one IFTTT trigger?
I have no idea how your IFTTT is set up. My ifttt sends me a text message with the contents of value1 being sent as the message. The IFTTT Applet Name is “HomeAssistantValue1”, and my message is “Main Door Open”. This is my example:
- alias: Message trigger on main door
trigger:
- platform: state
entity_id: sensor.main_door_hindge
to: 'open'
action:
- service: ifttt.trigger
data: {"event":"HomeAssistantValue1","value1":"Main Door Open"}
Written out like your example, it would look like this:
- alias: Message trigger on main door
trigger:
- platform: state
entity_id: sensor.main_door_hindge
to: 'open'
action:
- service: ifttt.trigger
data:
event: "HomeAssistantValue1"
value1: "Main Door Open"
You are going to need to make an on & off trigger for each device.
Why are you using IFTTT to turn on and off lights anyways? There are so many better ways. What type of device is this?
Actually, I don’t really need it for this. I’m using a script to control some LightwaveRF lights, and I was using IFTTT while I had a problem with them.
I guess I was more interested in learning to use IFTTT in different ways with Home Assistant than controlling these particular lights
I get ya. You like to tinker! That’s all I’ve done with my automation since I got it. I wish I could help you further, but I’ve only set up Text messaging… I haven’t really investigated other IFTTT uses aside from notifications.
I have managed to set up a trigger on/off that is integrated HA => IFTTT, but how to make integration working two ways? That if somebody pushes the button on the physical switch the state in HA will be updated?
Probably something like this:
trigger: ifttt
action: state
But I have no idea how to set it up properly
my setup in automations.yaml
- alias: turn on when sonoff_light_bedroom_b switch on
trigger:
- platform: state
entity_id: input_boolean.sonoff_light_bedroom_b
to: 'on'
action:
- service: ifttt.trigger
data: {"event":"sonoff_light_bedroom_b_on"}
- alias: turn off when sonoff_light_bedroom_b switch off
trigger:
- platform: state
entity_id: input_boolean.sonoff_light_bedroom_b
to: 'off'
action:
- service: ifttt.trigger
data: {"event":"sonoff_light_bedroom_b_off"}