Add Support for Smart Life Components

thats unrelated, that’s talking about network discovery having issues connecting to a found device.

Also, you still aren’t using your scripts inside the switch template…

nevermind i missed the first service

Sorry not too knowledgeable about using scripts…just doing this for the first time. Any help you can further provide would be great.

Thanks!

try putting your stuff in single quotes, for the event data and value1 data:

switch:
  - platform: template
    switches:
      raspi_switch:
        value_template: "{{ is_state('input_boolean.raspi_boolean') }}"
        turn_on:
          - service: ifttt.trigger
            data:
              event: 'raspi_switch_on'
              value1: 'on'
          - service: input_boolean.turn_on
            entity_id: input_boolean.raspi_boolean
        turn_off:
          - service: ifttt.trigger
            data:   
              event: 'raspi_switch_off'
              value1: 'off'
          - service: input_boolean.turn_off
            entity_id: input_boolean.raspi_boolean

Thanks again, but it still is not working. Is there anything I have to do within home assistant? Any services, states, events, I have to set or fire?

Thanks!

I mean, you have to use the switch in order for the ifttt to actually send the commands

forgot to add the on:

switch:
  - platform: template
    switches:
      raspi_switch:
        value_template: "{{ is_state('input_boolean.raspi_boolean','on') }}"
        turn_on:
          - service: ifttt.trigger
            data:
              event: 'raspi_switch_on'
              value1: 'on'
          - service: input_boolean.turn_on
            entity_id: input_boolean.raspi_boolean
        turn_off:
          - service: ifttt.trigger
            data:   
              event: 'raspi_switch_off'
              value1: 'off'
          - service: input_boolean.turn_off
            entity_id: input_boolean.raspi_boolean
2 Likes

Yeah…but nothing other than that?

Nope, jsut that. When you flip the switch off, it will execute the services in the turn_off catagory. You need to make sure you aren’t using the input_boolean… You need to use the switch. Hide the input boolean

Yeah, I don’t know why its not working. Can’t seem to figure it out. Since I’m not going to be switching this smart plug on and off too often (maybe once a month or so) I think I might go back to your previous method you posted.

Thanks for all your help though. I really appreciate it.

Ok nevermind. The code you provided worked perfectly! Thanks so much. Turns out that the IFTTT events were case sensitive and would only allow lower case. So I ensured the events in IFTTT were all lower case and ensured my configuration.yaml file contained lower cases and now it works great! I’m new to this coding, but thanks so much for being patient with me.

Thanks!

For anyone else interested, here’s the code that works for me (Thanks @petro)

input_boolean:
  raspi_boolean:
    initial: off  

switch:
  - platform: template
    switches:
      raspi_switch:
        value_template: "{{ is_state('input_boolean.raspi_boolean','on') }}"
        turn_on:
          - service: ifttt.trigger
            data:
              event: 'raspi_switch_on'
              value1: 'on'
          - service: input_boolean.turn_on
            entity_id: input_boolean.raspi_boolean
        turn_off:
          - service: ifttt.trigger
            data:   
              event: 'raspi_switch_off'
              value1: 'off'
          - service: input_boolean.turn_off
            entity_id: input_boolean.raspi_boolean
1 Like

Quick question…if I want to add more switches, do I need to create a new boolean for each switch?

IFTTT do not works with my Smart Life sockets :frowning:

I have been following this thread, I´m trying to control a smart life swith from HA. Of course you know that IFTTT doesnt work with smart life for tunring it on/off, you can only activate scenes. At the end this method can manage the switch form HA? If this is correct could you explain the steps for a noob please.

I understand I need to add the input boolean and the switch on the configuration.yaml, but I dont understand what I need to do on IFTTT.

Thanks for your help

Only if you want the state to be stored. This is a work around to the issue that input_booleans have. So it’s a goofy solution. If you can think of another way to store the state of the switch, use that. This is the band-aid that I’ve been using.

Not true :slight_smile:
Mine works just fine

Howdy!

Smart Life does work with IFTTT for turning a switch on/off. That’s what I’m using now. If you’re using IFTTT on your smart phone make sure its updated to the latest version. If you’re using it on your PC then you’re all good. Try these steps and let me know if they work for you: This assumes that you already followed the directions here https://www.home-assistant.io/components/ifttt/ and have obtained your IFTTT API key and all that good stuff.

  1. In the Smart Life app, ensure that your plug is connected and you can turn it on and off. Take note of the name of the plug as well.
  2. In IFTTT create a “New Applet”, click on “This”, and select “Webhooks”, then “Receive a Web Request”.
  3. Name the event. I suggest you use lower case and “_” as I experienced issues when I did not. For example, “test_plug_on”. Once named, click “Create Trigger”.
  4. Click “That” and select “Smart Life” from the action service list (just type it in).
  5. You’ll see that Smart Life has six actions to choose from (Turn On, Turn Off, Activate Scene, Set Light Brightness and Set Light Color). Choose “Turn On”.
  6. On the next screen select your plug and then click “Create Action”.
  7. Click “Finish” (I uncheck the receive notifications option but you can leave it if you want).

When you’re done, test your code to make sure it turns on. Once confirmed, follow the same steps, but in this case name your action something different (e.g. “test_plug_off”) and change the action in step 5 to “Turn Off”. Follow the rest of the steps and check your code.

This worked quite well for me and the response time is usually 3 seconds or less.

Hope this helps!

-Scott

2 Likes

cscotty thanks for the help, in some way I did it.

I did it, now I´m able to control the switch from HA. but as Ulisses_Nogueira said, I have to use SCENES for this, like a SCENE to turn just the plug, because when I go to TURN ON option, in WHICH DEVICE/GROUP, the only thing is OPTIONS UNAVAILABLE.
Its weird because IFTTT recognized my created scenes but it doesnt show the plug. Of course I can manage the switch from the smart life app.
Anyway thanks, its not perfect but really nice.

That’s strange. For me my devices shows up. Same devices listed in Smart Life show up in IFTTT as devices and not scenes. See my pictures for proof.