Hello community,
I want to pass the value from an “Open Windows / Doors count”
sensor (sensor.door_window_count) to a Homematic system variable
(OpenWindowsCount). The sensor.door_window_count is created
with the following template:
- platform: template
sensors:
door_window_count:
friendly_name: "Anzahl Fenster/Türen offen"
entity_id:
- binary_sensor.tk_eingang_state
- binary_sensor.tk_keller_state
- binary_sensor.fk_arbeitgarten_state
value_template: >
{{ states.binary_sensor
| selectattr('state', 'eq', 'on')
| selectattr('attributes.device_class', 'eq', 'opening')
| list
| count
| int}}
The HomeMatic system variable is defined like that:
The automation which is not working looks like that:
- alias: open_windows_to_HM
initial_state: true
trigger:
- entity_id: sensor.door_window_count
platform: state
action:
- service: persistent_notification.create
data:
title: "Open Windows"
message: Count = {{states('sensor.door_window_count')|float}}
notification_id: windows
- service: homematic.set_variable_value
data:
entity_id: homematic.ccu2
name: OpenWindowsCount
value: "{{states('sensor.door_window_count')|float}}"
Passing the count of open windows/doors to the notification service works, but giving
it to the homematic.set_variable_value service throws the following error:
Blockquote
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/automation/init.py”, line 431, in action
await script_obj.async_run(variables, context)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 151, in async_run
await self._handle_action(action, variables, context)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 235, in _handle_action
await self._actions[_determine_action(action)](action, variables, context)
File “/usr/src/homeassistant/homeassistant/helpers/script.py”, line 318, in _async_call_service
context=context,
File “/usr/src/homeassistant/homeassistant/helpers/service.py”, line 98, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context
File “/usr/src/homeassistant/homeassistant/core.py”, line 1235, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File “/usr/src/homeassistant/homeassistant/core.py”, line 1262, in _execute_service
await self._hass.async_add_executor_job(handler.func, service_call)
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/homeassistant/homeassistant/components/homematic/init.py”, line 470, in _service_handle_value
hub.hm_set_variable(name, value)
File “/usr/src/homeassistant/homeassistant/components/homematic/init.py”, line 855, in hm_set_variable
value = float(value)
ValueError: could not convert string to float: “{{states(‘sensor.door_window_count’)|float}}”
Blockquote
Have also tried to implement it this way will also not work:
- service: homematic.set_variable_value
data:
entity_id: homematic.ccu2
name: OpenWindowsCount
value: [sensor.door_window_count]
“TypeError: float() argument must be a string or a number, not ‘NodeListClass’”
Please help! Regards BP.