blueprint: name: Smart Rocker Switch for virtual control of Smart Light description: > Blueprint to control a smartlight that is always connected to power with a tradicional rocker switch equiped with a smartmodule. Operation: - If the light is OFF, 1 comutation will turn ON; - If the light is ON, 1 comutation withing specified time will turn OFF; - If the light is ON, and there are 2 comutations withing specified time, it will cycle between 3 brightness settings: 50% → 95% → 50% → 5% → 50% → ... (minumum and maximum brightness and color temperature adjustable). domain: automation input: interruptor: name: Switch description: Rocker switch with smart module selector: entity: domain: switch luz: name: Light description: Smart light to control (always connected to power) selector: entity: domain: light tempo: name: Delay description: The delay, in milliseconds, to consider (500-1500). default: 800 selector: number: min: 500 max: 1500 unit_of_measurement: ms brilho_min: name: Minimum brightness description: The minumum brightness, in percentage. default: 5 selector: number: min: 1 max: 25 unit_of_measurement: '%' brilho_max: name: Maximum brightness description: The maximum brightness, in percentage. default: 95 selector: number: min: 75 max: 100 unit_of_measurement: '%' kelvin_min: name: Minimum Kelvin description: The color temperature, in Kelvin, for the minimum brigtness. default: 3000 selector: number: min: 2700 max: 6500 unit_of_measurement: K kelvin_max: name: Maximum Kelvin description: The color temperature, in Kelvin, for the maximum brigtness. default: 5500 selector: number: min: 2700 max: 6500 unit_of_measurement: K trigger: - platform: state entity_id: - !input interruptor from: 'off' to: 'on' - platform: state entity_id: - !input interruptor from: 'on' to: 'off' variables: var_tempo: !input tempo var_brilho_min: !input brilho_min var_brilho_max: !input brilho_max var_kelvin_min: !input kelvin_min var_kelvin_max: !input kelvin_max action: - if: - condition: state entity_id: !input luz state: 'off' then: - service: light.turn_on target: entity_id: !input luz data: {} else: - wait_for_trigger: - platform: state entity_id: - !input interruptor to: timeout: milliseconds: '{{ var_tempo }}' - if: - condition: template value_template: '{{ wait.remaining == 0 }}' then: - service: light.turn_off target: entity_id: !input luz data: {} else: - choose: - conditions: - condition: numeric_state entity_id: !input luz above: 178 attribute: brightness sequence: - service: light.turn_on target: entity_id: !input luz data: brightness_pct: 51 kelvin: '{{ (var_kelvin_min + var_kelvin_max) / 2 }}' - conditions: - condition: numeric_state entity_id: !input luz above: 130 attribute: brightness sequence: - service: light.turn_on target: entity_id: !input luz data: brightness_pct: '{{ var_brilho_min }}' kelvin: '{{ var_kelvin_min }}' - conditions: - condition: numeric_state entity_id: !input luz above: 129 below: 131 attribute: brightness sequence: - service: light.turn_on target: entity_id: !input luz data: brightness_pct: '{{ var_brilho_min }}' kelvin: '{{ var_kelvin_min }}' - conditions: - condition: numeric_state entity_id: !input luz above: 127 below: 130 attribute: brightness sequence: - service: light.turn_on target: entity_id: !input luz data: brightness_pct: '{{ var_brilho_max }}' kelvin: '{{ var_kelvin_max }}' - conditions: - condition: numeric_state entity_id: !input luz above: 76 attribute: brightness sequence: - service: light.turn_on target: entity_id: !input luz data: brightness_pct: '{{ var_brilho_max }}' kelvin: '{{ var_kelvin_max }}' - conditions: - condition: numeric_state entity_id: !input luz below: 77 attribute: brightness sequence: - service: light.turn_on target: entity_id: !input luz data: brightness_pct: 50 kelvin: '{{ (var_kelvin_min + var_kelvin_max) / 2 }}' mode: single