Setup an On/Off IFTTT switch?

I don’t know anything about sonoff, I guess it doesn’t report the state (on or off) in HA. Is that correct? If so, I don’t know how flicking the physical switch could be reported back to HA.

Does the code for the switch automation above work OK?

That is most certainly not correct.

Ah, in that case you should (@Bartek_Pes) be able to create an automation that updates the input_boolean you’ve created when the switch is manually turned on or off.

But if sonoff can report it’s state in Home Assistant then presumably you can control it with Home Assistant as well, so not sure why you want to control it through IFTTT instead of directly though HA :slightly_smiling_face:

It is certainly possible to do but I just don’t know how to configure that automation. How to set up automation on HA and action in IFTTT. Maybe somebody can help with that.

As you see I suck in HA subject, so currently I don’t want to relay on HA combined with my (lack of) skills. Thanks to that I can play with HA and my wife is happy that Google home works without breaks :smiley:

Meanwhile, I have found other great solution: https://github.com/peterbuga/HASS-sonoff-ewelink
But anyway it would be nice to know how to set up that automation to be able to control devices/services that are not compatible with HA

Assuming you want to turn on light b when another light is switched on (light a?), then this should work:

- alias: turn on light a when sonoff_light_bedroom_b switched on
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: switch.sonoff_light_bedroom_a
    to: 'on'
  action:
    - service: ifttt.trigger
      data: {"event":"sonoff_light_bedroom_b_on"}


- alias: turn off light a when sonoff_light_bedroom_b switched off
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: switch.sonoff_light_bedroom_a
    to: 'off'
  action:
    - service: ifttt.trigger
      data: {"event":"sonoff_light_bedroom_b_off"}

I need the other way connection, IFTTT as a trigger and switching boolen as an action.

Ah, in that case you would use a webhook from IFTTT to make an API call to Home Assistant (or call the recently added HA webhooks from IFTTT’s webhooks). How would you trigger this from IFTTT?

For example, before Google Assistant/Google Home was directly integrated into Home Assistant I used to use the Google Assistant trigger on IFTTT as the first part, then the webhook service to make an API call to Home Assistant (the second part).

So in your case you could make a trigger from IFTTT that would turn on an input boolen in HA, or run a script to turn on the input boolen (can’t remember if you can turn on an input boolen directly from the API or if you need to run a script to turn on the input boolen).