blueprint: name: Milight Remote domain: automation author: Soif source_url: https://raw.githubusercontent.com/soif/hass_blueprints/refs/heads/master/blueprints/automation/milight_remote/milight_remote.yaml homeassistant: min_version: 2024.6.0 description: " **Version: 1.00**\n \n Links Milight remote buttons to light entities, using an ESP8266 Milight Hub as the RF/MQTT gateway.\n \n ![Dynamic JSON Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fsoif%2Fhass_blueprints%2Frefs%2Fheads%2Fmaster%2Fblueprints%2Fautomation%2Fmilight_remote%2Finfo.json&query=%24.version&label=Latest%20Version&color=red) [![Static Badge](https://img.shields.io/badge/Documentation-blue)](https://github.com/soif/hass_blueprints/tree/master/blueprints/automation/milight_remote) [![Static Badge](https://img.shields.io/badge/Forum_Thread-purple)](https://community.home-assistant.io/t/milight-remote-to-control-rgb-lights/820400) [![Buy me a beer](https://img.shields.io/badge/Buy_me_a_Beer-€5-AA0000?labelColor=ff0000)](https://www.buymeacoffee.com/soif) " input: mqtt: name: "### ESPMH MQTT Topic `milight/state/DEVICE_ID/DEVICE_TYPE/group_id`" icon: mdi:cog description: "Fill the DEVICE_ID and DEVICE_TYPE.\n *They can be found in the Milight Hub web interface on the 'Sniffer' page.*\n

" input: device_id: name: Device ID description: "from the MQTT topîc" default: "0x19EF" selector: text: device_type: name: Device Type description: "from the MQTT topîc" default: "rgb_cct" selector: text: buttons: name: "### Lights" icon: mdi:lightbulb-multiple description: "Define light entities to be controlled by each Zone button.\n

" input: light0: name: Zone 0 (Master) Lights description: "This is normally the Master zone switch. Leave it blank to control all other defined lights below. Else to act as an independant switch, fill the entities to be controlled" default: [] selector: entity: multiple: true filter: domain: - light light1: name: Zone 1 Lights description: "" default: [] selector: entity: multiple: true filter: domain: - light light2: name: Zone 2 Lights description: "" default: [] selector: entity: multiple: true filter: domain: - light light3: name: Zone 3 Lights description: "" default: [] selector: entity: multiple: true filter: domain: - light light4: name: Zone 4 Lights description: "" default: [] selector: entity: multiple: true filter: domain: - light light5: name: Zone 5 Lights description: "" default: [] selector: entity: multiple: true filter: domain: - light light6: name: Zone 6 Lights description: "" default: [] selector: entity: multiple: true filter: domain: - light light7: name: Zone 7 Lights description: "" default: [] selector: entity: multiple: true filter: domain: - light light8: name: Zone 8 Lights description: "" default: [] selector: entity: multiple: true filter: domain: - light trigger_variables: device_id: !input device_id device_type: !input device_type triggers: - trigger: mqtt topic: "milight/state/{{ device_id }}/{{ device_type }}/0" variables: light0: !input light0 light1: !input light1 light2: !input light2 light3: !input light3 light4: !input light4 light5: !input light5 light6: !input light6 light7: !input light7 light8: !input light8 light_target: >- {% if light0 ==[] %} {{ light1 + light2 + light3 + light4 + light5 + light6 + light7 + light8 }} {% else %} {{ light0 }} {% endif %} - trigger: mqtt topic: "milight/state/{{ device_id }}/{{ device_type }}/1" variables: light_target: !input light1 - trigger: mqtt topic: "milight/state/{{ device_id }}/{{ device_type }}/2" variables: light_target: !input light2 - trigger: mqtt topic: "milight/state/{{ device_id }}/{{ device_type }}/3" variables: light_target: !input light3 - trigger: mqtt topic: "milight/state/{{ device_id }}/{{ device_type }}/4" variables: light_target: !input light4 - trigger: mqtt topic: "milight/state/{{ device_id }}/{{ device_type }}/5" variables: light_target: !input light5 - trigger: mqtt topic: "milight/state/{{ device_id }}/{{ device_type }}/6" variables: light_target: !input light6 - trigger: mqtt topic: "milight/state/{{ device_id }}/{{ device_type }}/7" variables: light_target: !input light7 - trigger: mqtt topic: "milight/state/{{ device_id }}/{{ device_type }}/8" variables: light_target: !input light8 conditions: [] actions: - choose: - conditions: - condition: template value_template: "{{ trigger.payload_json.state =='ON' }}" sequence: - action: light.turn_on data: rgb_color: - "{{ trigger.payload_json.color.r }}" - "{{ trigger.payload_json.color.g }}" - "{{ trigger.payload_json.color.b }}" brightness_pct: >- {% if trigger.payload_json.brightness is defined %} {{ (trigger.payload_json.brightness / 255 * 100)| int }} {% else %} 100 {% endif %} target: entity_id: "{{ light_target }}" - conditions: - condition: template value_template: "{{ trigger.payload_json.state =='OFF' }}" sequence: - action: light.turn_off target: entity_id: "{{ light_target }}" data: {} mode: single