MiLight Status Feedback with NodeMCU!

Hi @Sthope,

MiLight supports 9 effects however they are called “mode”. With the setup for the light included in the message above, the automation would be:
automation

- alias: Effect2Mode
  initial_state: True
  trigger:
    - platform: mqtt
      topic: 'milight_gw/+/rgb_cct/+'
  condition: 
    condition: template
    value_template: '{{ "effect" in trigger.payload }}'  
  action:
    - service: mqtt.publish
      data_template:
        topic: "milight_gw/{{ trigger.topic.split('/')[-3] }}/rgb_cct/{{ trigger.topic.split('/')[3] }}"
        payload_template: '{ "mode": {{ trigger.payload_json.effect }} }'

The topics used in the webpage are as following:

mqtt_topic_pattern:
milight_gw/:device_id/:device_type/:group_id

mqtt_update_topic_pattern:
milight_gw/update/:device_id/:device_type/:group_id

mqtt_state_topic_pattern:
milight_gw/state/:device_id/:device_type/:group_id

In automation/script the action part that calls for effects would be:

- service: light.turn_on
  data_template:
    entity_id: light.light_id
    effect: any from 0 to 9

I use scripts (3 categories, for day, sunset and night) that are called from automations as the scenes do not allow for templating. This way, lights can be turned on with dimming and either white light (color temp) or color leds (providing separate r, g and b values).

Color names can be used (any color from CSS Color Module Level 3) with “color_name: xx”. I’ve made an input list with all of them (however some would resolve to white light) and use the option color_name: ‘{{ states.input_select.scenes_color_name.state}}’

Random colors can be used with rgb_color: [‘{{range(1,255)|random}}’, ‘{{range(1,255)|random}}’, ‘{{range(1,255)|random}}’]

MiLight platform doesn’t support transition but can be easily done with a script: