Recently I switched from a Fibaro HC2 to Home Assistant (the Fibaro broke down). I used to have some scripts on the HC2 to adjust the brightness of my Hue lights according to the value of the Fibaro Dimmer 2. However, I cannot seem to read the value of the dimmer in the Service call to set the brightness of the Hue lights.
Below the current version of the YAML:
alias: GameKamer_HueBrightnessChangeWithDimmer
description: ""
trigger:
- platform: device
device_id: be22d8ca284821c12248ff5afeea586f
domain: zwave_js
type: zwave_js.value_updated.value
command_class: 32
property: currentValue
endpoint: "1"
condition: []
action:
- target:
entity_id: d5db0a5ec03108ba2114a73ac063c6ad
data:
brightness_pct: "{{ 'trigger.current_value' | float }}"
action: light.turn_on
mode: single
This will give an error in the trace:
Error: Error rendering data template: ValueError: Template error: float got invalid input ‘trigger.current_value’ when rendering template ‘{{ ‘trigger.current_value’ | float }}’ but no default was specified
When I add a default for the float, it works, but that is not what I want.
In the ‘Changed variables’ tab of the trace I see the following values, where current_value is the one I need:
this:
entity_id: automation.gamekamer_flashlightsonvaluechange
state: 'on'
attributes:
id: '1723233019747'
last_triggered: '2024-08-09T20:19:10.377505+00:00'
mode: single
current: 0
friendly_name: GameKamer_HueBrightnessChangeWithDimmer
last_changed: '2024-08-09T20:17:20.581666+00:00'
last_reported: '2024-08-09T20:19:10.382063+00:00'
last_updated: '2024-08-09T20:19:10.382063+00:00'
context:
id: 01J4WCQ3X8YV3MTNRGWNHKWE7N
parent_id: null
user_id: null
trigger:
id: '0'
idx: '0'
alias: null
platform: zwave_js.value_updated
device_id: be22d8ca284821c12248ff5afeea586f
node_id: 3
command_class: 32
command_class_name: Basic
property: currentValue
property_name: currentValue
endpoint: 1
property_key: null
property_key_name: null
previous_value: 80
previous_value_raw: 80
current_value: 80
current_value_raw: 80
description: >-
Z-Wave value 3-32-1-currentValue updated on Fibaro Dimmer 2 Zolder Links
Main
I have also tried to change the variable I try to read in the brightness_pct property to ‘trigger.to_state.state’ but that also gives the same error.
I have read a lot of post on this community and Automation YAML - Home Assistant but I think I still miss some of the logic.
Does anyone know what I do wrong here?