Pełna konfiguracja pilota IKEA czyli funkcjonalność taka sama jak przy sparowaniu z żarówką:
To rozwiązanie działa na pewno bo mam u siebie.
Dodanie wpisu do configuration.yaml
python_script:
wgranie poniższego skryptu do python_scripts
/data/data/pl.sviete.dom/files/home/AIS/python_scripts/change_attribute_light_smoothly.py
input_boolean = data.get("input_boolean") light_id = data.get("light_id") delta = data.get("delta") attribute_id = data.get("light_attribute", "brightness") delay = data.get("delay", 350) attribute_mapping = { "brightness": {"min": 1, "max": 255}, "color_temp": {"min": 153, "max": 500}, } exit_service = False while True: switch_input = hass.states.get(input_boolean).state if switch_input == "off": break light = hass.states.get(light_id) attr_value = light.attributes[attribute_id] attr_value = attr_value + delta if attr_value < attribute_mapping[attribute_id]["min"]: attr_value = attribute_mapping[attribute_id]["min"] exit_service = True elif attr_value > attribute_mapping[attribute_id]["max"]: attr_value = attribute_mapping[attribute_id]["max"] exit_service = True service_data = {"entity_id": light_id, attribute_id: attr_value} logger.warning(f"Service data: {service_data}") hass.services.call("light", "turn_on", service_data) if exit_service: break time.sleep(delay / 1000)
Automatyzacja rozjaśnianie i ściemnianie
- id: '1582141424335' alias: Zigbee Pilot Brightness Up description: '' trigger: - entity_id: sensor.pilot_ikea01_action platform: state to: brightness_up_click condition: [] action: - data_template: brightness: '{{ state_attr("light.0xccccccfffe6cdc2c_light", "brightness") + 50 | int }}' entity_id: light.0xccccccfffe6cdc2c_light service: light.turn_on - id: '1582141544141' alias: Zigbee Pilot Brightness Down description: '' trigger: - entity_id: sensor.pilot_ikea01_action platform: state to: brightness_down_click condition: [] action: - data_template: brightness: '{{ [state_attr("light.0xccccccfffe6cdc2c_light", "brightness") - 50, 1] | max }}' entity_id: light.0xccccccfffe6cdc2c_light service: light.turn_on
A tutaj zmiana barwy światła:
- id: ikea_controller_warm_up
alias: Ikea controller warm up
trigger:
platform: state
entity_id: sensor.pilot_ikea01_action
to: arrow_right_click
action:
data_template:
entity_id: light.0xccccccfffe6cdc2c_light
color_temp: "{{ state_attr('light.0xccccccfffe6cdc2c_light', 'color_temp') + 75 }}"
service: light.turn_on
- id: ikea_controller_warm_down
alias: Ikea controller warm down
trigger:
platform: state
entity_id: sensor.pilot_ikea01_action
to: arrow_left_click
action:
data_template:
entity_id: light.0xccccccfffe6cdc2c_light
color_temp: "{{ state_attr('light.0xccccccfffe6cdc2c_light', 'color_temp') - 75 }}"
service: light.turn_on
Kolejne automatyzacje przy przytrzymaniu przycisków rozjaśniania/ściemniania i zmiany barwy
- id: ikea_controller_brighten_on alias: Ikea Controller - Brighten on trigger: - platform: state entity_id: sensor.pilot_ikea01_action to: brightness_up_hold condition: - condition: state entity_id: light.0xccccccfffe6cdc2c_light state: "on" action: - service: input_boolean.turn_on entity_id: input_boolean.light_brightness - service: python_script.change_attribute_light_smoothly data: light_id: light.0xccccccfffe6cdc2c_light input_boolean: input_boolean.light_brightness delta: 20 - id: ikea_controller_brighten_off alias: Ikea Controller - Brighten off trigger: - platform: state entity_id: sensor.pilot_ikea01_action to: brightness_down_hold condition: - condition: state entity_id: light.0xccccccfffe6cdc2c_light state: "on" action: - service: input_boolean.turn_on entity_id: input_boolean.light_brightness - service: python_script.change_attribute_light_smoothly data: light_id: light.0xccccccfffe6cdc2c_light input_boolean: input_boolean.light_brightness delta: -20 - id: ikea_controller_brighten_dim_off alias: Ikea Controller - Brighten/Dim off initial_state: "on" trigger: - platform: state entity_id: sensor.pilot_ikea01_action to: brightness_up_release - platform: state entity_id: sensor.pilot_ikea01_action to: brightness_down_release condition: condition: and conditions: - condition: state entity_id: input_boolean.light_brightness state: "on" - condition: state entity_id: light.0xccccccfffe6cdc2c_light state: "on" action: - service: input_boolean.turn_off entity_id: input_boolean.light_brightness - id: ikea_controller_warm_on alias: Ikea Controller - Warm on trigger: - platform: state entity_id: sensor.pilot_ikea01_action to: arrow_right_hold condition: - condition: state entity_id: light.0xccccccfffe6cdc2c_light state: "on" action: - service: input_boolean.turn_on entity_id: input_boolean.light_color_temp - service: python_script.change_attribute_light_smoothly data: input_boolean: input_boolean.light_color_temp light_id: light.0xccccccfffe6cdc2c_light light_attribute: color_temp delta: 40 - id: ikea_controller_col_on alias: Ikea Controller - Cold on trigger: - platform: state entity_id: sensor.pilot_ikea01_action to: arrow_left_hold condition: - condition: state entity_id: light.0xccccccfffe6cdc2c_light state: "on" action: - service: input_boolean.turn_on entity_id: input_boolean.light_color_temp - service: python_script.change_attribute_light_smoothly data: light_id: light.0xccccccfffe6cdc2c_light input_boolean: input_boolean.light_color_temp light_attribute: color_temp delta: -40 - id: ikea_controller_warm_cold_off alias: Ikea Controller - Warm/Cold off initial_state: "on" trigger: - platform: state entity_id: sensor.pilot_ikea01_action to: arrow_left_release - platform: state entity_id: sensor.pilot_ikea01_action to: arrow_right_release condition: condition: and conditions: - condition: state entity_id: input_boolean.light_color_temp state: "on" - condition: state entity_id: light.0xccccccfffe6cdc2c_light state: "on" action: - service: input_boolean.turn_off entity_id: input_boolean.light_color_temp