@samuscherer mine is a KMC 70011 displays the same as Coolie1101’s
Won’t be able to help with the bulb but hopefully help with the plug. First make a note of the IP address of your socket before you remove it from the app you’re using now. Remember to port forward your router to 6668 to 6668 to the IP address of the socket.
Just wanted to confirm, port forwarding needs to be done to the socket and not the Phone/App, and if so, I would need to do this for each socket, one at a time using the same port?
Think so, but someone much more intelligent than me might correct that, but i’m going for what worked for me.
Does anyone know if these work with Google home once added to home assistant?
I want to move away from the Tuya Smart app however I like to still be able to control devices with my Google home mini
For me they worked, so I suppose they will work for you too. I just exposed the “switches” domain and they popped up in my Google home app
Can you go into a bit more detail about your process?
I didn’t get around to trying it last night as I was stuck at a PTO board meeting for my daughter’s school. Hope to have time tonight though
What i’ve Heard that Paulus is working on Google integration at the moment so I think an easier way is coming soon.
Hi All,
Another vote added!
I wasn’t able to follow the solution that was posted in this forum, but I was able to work it out from what I read here: Setup an On/Off IFTTT switch?
I have purchased a three pack of these switches here for $20:
https://www.amazon.com/gp/product/B07313TH7B/
I connected these devices to IFTTT using webhooks/maker event and created rules to turn the switches on and off (self explanatory in IFTTT). Then I entered this script into my configuration.yaml file:
input_boolean:
test_switch:
name: Test Switch
initial: off
automation:
- alias: turn on when test switch on
trigger:- platform: state
entity_id: input_boolean.test_switch
to: ‘on’
action: - service: ifttt.trigger
data: {“event”:“Test_Switch_On”, “value1”:“on”}
- platform: state
- alias: turn off when test switch off
trigger:- platform: state
entity_id: input_boolean.test_switch
to: ‘off’
action: - service: ifttt.trigger
data: {“event”:“Test_Switch_Off”, “value1”:“off”}
- platform: state
When I flip the “test switch” switch in HA it turns the plug on or off depending on the current status.
Hope this helps
-Scott
Hey, just wanted to say thanks for this. You inspired me to finally dig into using IFTTT with HA and I got my Smart Life switch to work based on your example. Couldn’t quite get the direct Tuya integration to work for some reason, but this works great!
FYI, that is an older implementation. Since then, i’ve upgraded the script to be slightly better to use. The flaws of input_booleans is that they suppress ‘on’ when the state of the toggle is on, and they suppress off when the state of the toggle is off. You may not think this is important, but it has it’s limitations. Especially if the light gets out of sync with the button. A way around this is to use a template switch in combination with an input_boolean. The input_boolean is used to ‘store’ the state of the light in HA, while the template switch is used as the control of the device:
input_boolean:
my_boolean:
initial: off
switch:
- platform: template
switches:
my_iftttt_switch:
value_template: "{{ state('input_boolean.my_boolean') }}
turn_on:
- service: ifttt.trigger
data:
event: Test_Switch_On,
value1: on
- service: input_boolean.turn_on
entity_id: input_boolean.my_boolean
turn_off:
- service: ifttt.trigger
data:
event: Test_Switch_Off,
value1: off
- service: input_boolean.turn_off
entity_id: input_boolean.my_boolean
The benefit is that you don’t have multiple actions and your services are in 1 device. The drawback is that you have to hide the input_boolean.
Switch templates also are agnostic of the state of the switch. That means, if the device is off, you can still ‘turn it off’. So if it ever gets out of sync, you can just turn it off and it will turn off (unlike an input_boolean).
No prob! Glad I can help! All credit goes to @petro for sharing his script.
p.s. I see he has a newer implementation of the script. I’m gonna try and it as well.
Thanks for the help! I’m trying to switch to the new method but for some reason the switch wont work. The code is correct as I’ve run the check config on my configuration.yaml file and the switch appears. But when I flip the switch, the plug does not turn on. Here is my yaml file…see anything wrong? (ignore the indentation)
input_boolean:
test_switch:
initial: off
switch:
- platform: template
switches:
test_switch:
value_template: “{{ state(‘input_boolean.test_switch’) }}”
turn_on:
- service: ifttt.trigger
data:
event: Test_Switch_On
value1: on
- service: input_boolean.turn_on
entity_id: input_boolean.test_switch
turn_off:
- service: ifttt.trigger
data:
event: Test_Switch_Off
value1: off
- service: input_boolean.turn_off
entity_id: input_boolean.test_switch
Thanks,
Scott
the input boolean needs to be in it’s own section with other input booleans. Switch needs to be in its own section as well. I just wrote it that way so you guys could see it. Also, can you use the </> button to format the yaml?
Thanks again. Here’s my code posted correctly. This is the only thing I have on my configuration.yaml file in regards to input boolean and switches. Just doesn’t want to take. Any guess why? The switches show up fine on the HA launch page, but they do not call the IFTTT triggers. Any help is greatly appreciated. Thanks!
By the way, I did noticed that the two events I am calling “raspi_switch_off” and “raspi_switch_on” are not listed as available events in Home Assistant. Could this be the issue? If so, do you know how to get home assistant to recognize my IFTTT events?
input_boolean:
raspi_boolean:
initial: off
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
what are the errors in the logs?
Seems like there is a TypeError where a ‘state’ missing or something?
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 204, in async_update_ha_state
yield from self.async_device_update()
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 325, in async_device_update
yield from self.async_update()
File "/usr/lib/python3.5/asyncio/coroutines.py", line 210, in coro
res = func(*args, **kw)
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/switch/template.py", line 169, in async_update
state = self._template.async_render().lower()
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/template.py", line 132, in async_render
return self._compiled.render(kwargs).strip()
File "/srv/homeassistant/lib/python3.5/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/srv/homeassistant/lib/python3.5/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/srv/homeassistant/lib/python3.5/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "<template>", line 1, in top-level template code
File "/srv/homeassistant/lib/python3.5/site-packages/jinja2/sandbox.py", line 427, in call
return __context.call(__obj, *args, **kwargs)
TypeError: is_state() missing 1 required positional argument: 'state'
change:
value_template: "{{ is_state('input_boolean.raspi_boolean') }}"
to
value_template: "{{ is_state('input_boolean.raspi_boolean', 'on') }}"
Tried that as well. No dice. At least this time, when I flip the switch the toggle stays on…before it would toggle on and then a few seconds later toggle off. But in either case it would not turn on/off the smart plug. Weird the code you posted using automation works perfectly. Here is the error log entry:
2018-04-24 17:59:16 WARNING (Thread-18) [netdisco.ssdp] Found malformed XML at http://xxx.xxx.x.xxx:xxxx: status=ok
2018-04-24 17:59:16 WARNING (Thread-18) [netdisco.ssdp] Error fetching description at https://xxx.xxx.x.xxx:xxxx
Thanks!