I’ve been trying to get the temperature working for my IR aircon.
Besides creating the rest_command and switch in the config I created a climate/generic_thermostat like this:
In this particular case I used our air purifier as temperature sensor, but it’s probably best to use a zigbee or BLE temperature sensor instead. I’m still testing it, but so far it seems to work.
Yeah, I’m having the same issue. Right now, I have a card on a dashboard to control the curtains but no way of hooking it into automation. I’m trying to figure out a way of detecting motion outside the window and using that to close the curtain … (beginner here btw)
[quote=“shogun168, post:88, topic:270550, full:true”] I’m trying to figure out a way of detecting motion outside the window and using that to close the curtain … (beginner here btw)
[/quote]
I am using a Homematic Window sensor and call a cover service to open or close the curtains once motion is detected or not. Works pretty well.
I ended up using this cover template for the Curtain
cover:
- platform: template
covers:
bedroom_curtain:
device_class: curtain
friendly_name: "Bedroom Curtain"
#position_template: "{{ states('sensor.positie_woonkamer_gordijn') }}"
position_template: "{% if (states('sensor.positie_bedroom_curtain') | round | int) == 0 %}
100
{% else %}
{{ 100 % (states('sensor.positie_bedroom_curtain') | round | int) }}
{% endif %}" # my change using % (mod) to convert the value. if value is 0 it throws error in log about using mod on a value of 0. so place in the static value instead.
open_cover:
service: rest_command.switchbot_device_command
data:
deviceId: !secret switchbot_bedroom_deviceId
command: "setPosition"
parameter: "0,ff,0"
close_cover:
service: rest_command.switchbot_device_command
data:
deviceId: !secret switchbot_bedroom_deviceId
command: "setPosition"
parameter: "0,ff,100"
stop_cover:
service: rest_command.switchbot_device_command
data:
deviceId: !secret switchbot_bedroom_deviceId
command: "turnOff"
set_cover_position:
service: rest_command.switchbot_device_command
data:
deviceId: !secret switchbot_bedroom_deviceId
command: "setPosition"
parameter: "0,ff,{{position}}"```
Now I would like to add a webhook trigger to open or close the curtains via an automation. (receive webhook → open/close Curtains) But below code isn’t working, any idea what I’ve done wrong?
Thanks (dank je! :p), I noticed it showed closed when open and the other way around implementing the original solutions (made into an article by a youtuber, who refered back to this topic). Figured Switchbot and HA had a direct reverse interpetation of 0 and 100. This saved me having to do the math myself.
For those looking to integrate the Switchbot Lock, figured I’d share my code (shamelessly stolen and adapted from others). Note that Switchbot API Limit is 10,000/day so this will eat up over a quarter of that:
sup guys
love this community, and this discussion is just another good example of it
need some assistance. for some reason my “open” and “close” buttons are not working properly if the blinds are completely “close” or “open”.
let me elaborate.
buttons, sensor, and even the slider to control the switchbot - works great. however, if the blinds are 100% “open”, for some reason the “open” button on the dashboard is the only one that stays “pressable” (yet pressing it does nothing) while the “close” button is grayed out, and cant be pressed.
the “stop” button is useable as “close” button.
for now, i “reversed” the actions of the buttons - (close button actually open the blinds, and vice versa) but that cant be the “right” way to go…
i’d love some help, if anyone have any experience with this, or knows whats need to be done to fix it…
cheers
The API and HA are reversed how they see 100 and 0. There is a post in this topic how to adapt your code for this. I’m not behind a computer else I would look it up. Scroll through the topic and you will find it.
thanks for the pointer, i did try it, but it didnt work for me. not sure what i did wrong. so for now, im back to my “reverse definitions”, as the “open” button closes the blinds and vice versa. not ideal, but its fine. ill add a costume card with some buttons for better UI experience, and for the automations it doesn’t really matter anyway.
With the new HA release and renewed Bluetooth support I can now find my curtainbots without having to the use the API route. With me they don’t respond yet (but show status correctly), probably due to the distance. It may be worth investigating for you as if the distance isn’t to big. Will prevent a lot of tinkering with the API.
When you say they don’t respond yet, are you seeing errors? I can add them but cannot control them even if the Pi is very close to them. I opened a ticket but not sure if this is an isolated issue to my Pi.
“curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - La fonction de révocation n’a pas pu vérifier la révocation du certificat.”
Can anyone tell me what i’m doing wrong ?
thanks
EDIT:
Finally found out after hours of searching and trying (and failing).
Just needed to add “–ssl-no-revoke” at the end of the powershell command.
So it must look like this: curl.exe -H "Authorization: YOUR_API" https://api.switch-bot.com/v1.0/devices/ --ssl-no-revoke
Just want to add my2cent, maybe helpful for others.
I use a switchbot hub mini sto remote control my air condition. As there is no integration that uses the api to control the hub, I found a workaround, that works good for me.
I set up different scenes in the hub mini for the air condition, then I set up webhook actions in IFTTT to start these scenarios.
With the IFTTT integration in HA it’s pretty easy to initiate these Szenarios now from inside HA.
I defined an input_select with all Szenarios as well as an automation which sends IFTTT triggers, based on the input_select.
I now can even select the input_select from within HomeKit incl. Siri and control my air condition.
Perfect for me.
I found the answer by myself… The lock/unlock function have been remove from the API by switchbot for “security reason”. On github they mentionned they work on a new version to reopen the function…