thanks for the great work. I put my meters and my hub (as IR-Controller) in ha. Most things are fine, but it would be nice, if the IR-Buttons work as ha-buttons and not like switches. Could you give me a hint, how i can use the HA-Buttons?
I was constantly struggling with the calibration of my curtains. It only happened with Home Assistant, so I knew it had to be specifically that. Iāve been messing around with the code for a little bit and now my curtains are completely closing again. It seems that turnOn and turnOff are not working properly.
I also saw the remarks about the greyed out close arrow. Since the API only asks for every 10 minutes, the arrow will be white/clickable after 10 minutes (in my experience). Thatās where the stop button comes in handy. That one will always close your curtain.
Below the code for what Iām using (based on the different templates that I got here)
The name is automatically slugified ( ā lower case, and spaces ā underscores ) by the integration and used as the entity object id. e.g.
name: 'Any Name Here'
is converted to:
sensor.any_name_here
Where, sensor is the domain, and any_name_here is the object_id of the entity_id
entity_id: domain.object_id
As long as you realise that changing the name changes the entity_id you can change it to pretty much anything you want. Be careful with symbols (slugified to underscores), and try not to start your name with numbers. object_ids beginning with numbers require special treatment in some circumstances.
When i use rest command to open my curtains my switchbot open more than it should ( More than my Calibration) and wheels trying to spin even when it max on the rail WHY? XD
I have 4 SwitchBot switches I use on some light switches that Iām having some difficulty properly integrating into HA and Iām hoping someone can help.
I got the device IDs by running this in in Terminal in macOSā¦
However, I quickly realized that itās not polling for updates so if I control it anywhere outside of HA it becomes out of sync and Iāve scanned through the dozens of posts above and see some sample code on how to poll for updates but Iām a bit unsure of how to actually apply it to configuration.yaml. Also as I have 4 different switches it seems a bit clunky to paste all the stuff above over and over again for each switch and Iām sure there is an easier way Iām just getting a bit twisted up trying to make it all work and looking for some help.
Anyone knows how to set 2 or more curtains?
I was able to follow the guide for only 1 pair of curtains. But what if I wanted to add another pair? If I type the same code twice, the first valid for the first pair and the second valid for the second pair, Home Assistant gives me an error.
The problem is the curtain position number. Home assistant is expecting position 0 to be closed and 100 to be open, where as switchbot reports it the opposite way round.
Refer to Template Cover - Home Assistant
position_template:
Defines a template to get the position of the cover. Legal values are numbers between ā0ā (closed) and ā100ā (open).
Switchbot reports 0 as open and 100 as closed.
The fix is to use the following in the position_template.
cover:
- platform: template
covers:
bedroom_curtains:
device_class: curtain
friendly_name: "Bedroom Curtains"
#position_template: "{{ states('sensor.bedroom_curtain_position') }}" # original
position_template: "{% if (states('sensor.bedroom_curtain_position') | round | int) == 0 %}
100
{% else %}
{{ 100 % (states('sensor.bedroom_curtain_position') | 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: "turnOn"
close_cover:
service: rest_command.switchbot_device_command
data:
deviceId: !secret switchbot_bedroom_deviceId
command: "turnOff"
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
The mod (%) math function provides the remainder value. You can google the mod math function but effectively it does the following.
I own about ten Switchbot Meters, but for some reason both the frequency of measurements wildly varies throughout the day both on the app, but especially when using the API. Is there anyone else also having these issues? The signal needs to only travel through one wall in one case, but in another case it goes through two.
Itās almost as if someone bought a signal jammer to mess up everything. Of course, itās possible that the large set of wireless technologies being used means that I am creating this problem myself without knowing about it.
Wireless systems in use: multiple (<5) wireless routers (2.4Ghz), zigbee coordinator, multiple Switchbot hubs, multiple accesspoints, multiple ESP32s running a Bluetooth4+ stacks + acting as WiFI client.
The environment is fairly public, so āanyoneā could theoretically bring a signal jammer. Itās more likely that someone just has a malfunctioning device or that there is some kind of interference from having too many devices.
Iām getting this error in the log when trying to use your mod:
Logger: homeassistant.helpers.template
Source: helpers/template.py:1286
First occurred: 14:24:53 (4 occurrences)
Last logged: 14:24:53
Template warning: āroundā got invalid input āunknownā when rendering template ā{% if (states(āsensor.livingroom_curtain_positionā) | round | int) == 0 %} 100 {% else %} {{ 100 % (states(āsensor.livingroom_curtain_positionā) | round | int) }} {% endif %}ā but no default was specified. Currently āroundā will return āunknownā, however this template will fail to render in Home Assistant core 2022.1
Template warning: āintā got invalid input āunknownā when rendering template ā{% if (states(āsensor.livingroom_curtain_positionā) | round | int) == 0 %} 100 {% else %} {{ 100 % (states(āsensor.livingroom_curtain_positionā) | round | int) }} {% endif %}ā but no default was specified. Currently āintā will return ā0ā, however this template will fail to render in Home Assistant core 2022.1
I have this working with my switchbot switch, but has anyone gotten the status to work with the switch? Iām still pretty new to home assistant and Iām not sure where to add the api status check.
Edit:
I think I have this working, someone please let me know if there is a better way to do this. Here is my config.yaml.
Looks like they updated their API to allow 10,000 polls a day so I have my single switch checking every 10 seconds. Iām also leaving out my secrets.yaml because itās the same as the examples above.
I saw some questions of people who are having another Switchbot curtain in another room, as I have tooā¦ I did not see any reponses. Can someone help with this code? Thanks a lot!