未測試, 可能還有沒考慮到的, 算是給個魚桿了
input_number:
light_blahblah_brightness: {initial: 0, min: 0, max: 255, step: 1}
sensor:
- platform: template
sensors:
light_blahblah_brightness:
value_template: '{{ states("input_number.light_blahblah_brightness") | int }}'
automation:
- alias: when_input_number_changed # input_number 數值變化時 反應至實際亮度
trigger:
- platform: state
entity_id: input_number.light_blahblah_brightness
action:
- service: light.turn_on
entity_id: light.blahblah
data_template:
brightness: '{{ states("input_number.light_blahblah_brightness") | int }}'
- alias: when_light_brightness_changed # HA 啟動時 以及 亮度 sensor 變化時 反應數值至 input_number
trigger:
- platform: state
entity_id: sensor.light_blahblah_brightness
- event: start
platform: homeassistant
action:
- service: input_number.set_value
entity_id: input_number.light_blahblah_brightness
data_template:
value: '{{ states("sensor.light_blahblah_brightness") | int }}'
|