Hello community,
I have the issue that my window covers with Somfy motors (integrated through Homekit and Velux Gateway) is working on a range from -100 to 100 (states in HomeAssistant developer tools)
current_tilt_position: -100
The problem I have is that HomeAssistent does not accept in automation negative values.
Failed to call service cover.set_cover_tilt_position. value must be at least 0 for dictionary value @ data[‘tilt_position’]. Got None
Can I translate in the integration “number * 2 - 100” to get numbers from -100 to 100 instead of 0 to 100?
Would be really great if I could close the venetian blinds fully through HomeAssistant …
Hi @AllHailJ
thanks, but the issue is not the template. Sorry for the misunderstanding.
The issue is that when I send “0” to the ‘cover.set_cover_tilt_position’ service the device needs to receive -100, but with your proposal or below the service refuses values below 0.
It may depend on the Integration. My thinking (based on how MQTT covers works) is that somewhere along the way, the integration needs to tell HA what the min tilt position (-100) and max tilt position (+100) are and HA translates this to a percentage 0 to 100%, and when the service call is made, it inverse translates this percentage to an absolute value (between -100 and +100).
Are you saying that when a call is made to the service with tilt position of 0 (%) and this does not move the tilt to -100? If not then it is probably worth reporting as a bug against that integration.
You could create a helper that represents the % closed 0-100 as an input_number (helper) in HA. Then with the use of the template feature, you set the number to send to Somfy.
#--------------------------------------------------------------------------------------------------
# Take an input number which represents % closed and map it to Somfy number Space
#--------------------------------------------------------------------------------------------------
template:
- sensor:
- name: "Closed Percent for Somfy"
unique_id: "Closed Percent for Somfy"
state: >
{% set closed = states('input_number.percent_closed') | int(0) %}
{{ closed * 2 - 100}}
Your entity would be sensor.closed_percent_for_somfy
I was curious and took a glance at the homekit integration code, and for tilt, I see the following comments for both updates from Homekit and sending to Homekit:
# HomeKit sends values between -90 and 90.
# We'll have to normalize to [0,100]
I’m not 100% sure, but the code seems to have tilt value operate within HA as values between 0 and 100 so it converts this to -90 and +90 when operating directly with Homekit. So again at a glance, since HA is showing a current_tilt_position that is negative, it would appear that Homekit, in this case via VeluxGateway and Somfy may actually operate on values that break this -90/+90 assumption. It would be hard to tell for sure without debug logs but I don’t see a debug log statement in the tilt position update part of the code.
Anyway, I would raise the issue on GitHub just to see what the developers may think about this.