Because templating with device_id’s is not supported, I believe you need to use entity_id’s to make this work. Device_id’s were intended for use with the UI editor and are not people friendly. I avoid them wherever I can, personally.
Tanks @Didgeridrew. That gave me a good jump forward, but still not completely there. Right now the temperature is 18° but all relays came off. Yes! now it worked (at least at the current temperature) Ended up like this (apparently the web based yaml editor removed all comments):
alias: Simuler temperatur
description: Angiver aktuel temperatur i Sal for fjernvarmeunit
trigger:
- platform: state
entity_id:
- sensor.simulator_vaerdi_2
condition: []
action:
- service: >-
light.turn_{{ 'on' if states("sensor.simulator_vaerdi_2") | int |
bitwise_and(1) else 'off' }}
target:
entity_id: 855c33ae0a49cdb1c6dfd1e4667179f4
- service: >-
light.turn_{{ 'on' if states("sensor.simulator_vaerdi_2") | int |
bitwise_and(2) else 'off' }}
target:
entity_id: 6679e11def8d7b93815029f919df1d8d
- service: >-
light.turn_{{ 'on' if states("sensor.simulator_vaerdi_2") | int |
bitwise_and(4) else 'off' }}
target:
entity_id: 6a4fc0bc6a02877797e44ea893f61e1f
- service: >-
light.turn_{{ 'on' if states("sensor.simulator_vaerdi_2") | int |
bitwise_and(8) else 'off' }}
target:
entity_id: cbbd0d2ee09146c56ee528a5bff59fa0
mode: restart