sidoh / esp8266_milight_hub

Replacement for a Milight/LimitlessLED hub hosted on an ESP8266
MIT License
931 stars 219 forks source link

Problem with syncing state of physical remote FUT B4 with Home Assistant #754

Closed kingnlfung closed 2 years ago

kingnlfung commented 2 years ago

Hi Guys,

I'm on this amazing journey to automate my lights using milight. Over the course of 1 week I've managed to build this addon and setup the Milight Hub and manually added the lights in a lights.yaml config.

I currently have been trying to sync physical remote with hass state for over a day now without success.

I have a ceiling light with 4 light bulbs. assigned to 0x0001 DeviceID group 1 - 4. These lights are working fine with HASS.

Below automation allows me to use Group 2 of my remote to turn on the 4 lights in 0x0001 DeviceID. However, I cannot get them to sync up.

I must have read the tutorial 10+ times scanning line by line but cannot get it to work.

Please share your advice?

#Milight forwarderd
- alias: MiLight Forwarder
  initial_state: true
  trigger:
    platform: mqtt
    topic: milight/updates/0x1A8A/rgb_cct/2
  action:
  - service: mqtt.publish
    data_template:
      topic: milight/commands/0x0001/rgb_cct/0
      payload_template: '{{ trigger.payload }}'

What is the model number of the device you're trying to control?

FUT B4 Wall panel (RGB+CCT)

What firmware version(s) have you tried?

1.10.8 (latest)

Which ESP8266 board are you using? (nodemcu, d1_mini, etc.)

Nodemcu

Which radio type are you using? (RGBW, RGB+CCT, etc.)

RGB+CCT

Have you tried controlling the device with a physical remote?

Yes

### Output of http://milight-hub.local/about and http://milight-hub.local/settings

/about

{"firmware":"milight-hub","version":"1.10.8","ip_address":"192.168.2.170","reset_reason":"Power on","variant":"nodemcuv2","free_heap":11552,"arduino_version":"2_4_2","queue_stats":{"length":0,"dropped_packets":0}}

/settings

{"admin_username":"","admin_password":"","ce_pin":4,"csn_pin":15,"reset_pin":0,"led_pin":-2,"radio_interface_type":"nRF24","packet_repeats":75,"http_repeat_factor":1,"auto_restart_period":0,"mqtt_server":"192.168.2.118:1883","mqtt_username":"xxx","mqtt_password":"xxx","mqtt_topic_pattern":"milight/commands/:device_id/:device_type/:group_id","mqtt_update_topic_pattern":"milight/updates/:device_id/:device_type/:group_id","mqtt_state_topic_pattern":"milight/states/:device_id/:device_type/:group_id","mqtt_client_status_topic":"milight/client_status","simple_mqtt_client_status":true,"discovery_port":48899,"listen_repeats":3,"state_flush_interval":10000,"mqtt_state_rate_limit":500,"mqtt_debounce_delay":500,"mqtt_retain":true,"packet_repeat_throttle_sensitivity":20,"packet_repeat_throttle_threshold":750,"packet_repeat_minimum":100,"enable_automatic_mode_switching":false,"led_mode_wifi_config":"Fast toggle","led_mode_wifi_failed":"On","led_mode_operating":"Slow blip","led_mode_packet":"Flicker","led_mode_packet_count":3,"hostname":"milight-hub","rf24_power_level":"MAX","rf24_listen_channel":"LOW","wifi_static_ip":"","wifi_static_ip_gateway":"","wifi_static_ip_netmask":"","packet_repeats_per_loop":75,"home_assistant_discovery_prefix":"homeassistant","wifi_mode":"n","default_transition_period":500,"rf24_channels":["LOW","MID","HIGH"],"device_ids":[1,2,3,4,17,18],"gateway_configs":[[1,1001,6],[2,1002,6],[3,1003,6],[4,1004,6],[5,1005,6],[6,1006,6],[7,1007,6],[8,1008,6],[9,1009,6],[16,1010,6],[17,1011,6],[18,1012,6],[19,1013,6],[20,1014,6]],"group_state_fields":["state","brightness","mode","color_temp","bulb_mode","computed_color"],"group_id_aliases":{}}
kingnlfung commented 2 years ago

Some further testing: Installed MQTT explorer.

Changed forwarder automation to:

- alias: MiLight Forwarder (0)
  initial_state: True
  trigger:
    platform: mqtt
    topic: milight/updates/0x1A8A/rgb_cct/2
#  condition:
#    - condition: template
#      value_template: >
#        {{ trigger.topic.split('/')[4] == '0' }}
  action:
    - service: mqtt.publish
      data_template:
        topic: "milight/0x0001/rgb_cct/1"
        payload_template: >
          {{ trigger.payload }}
    - service: mqtt.publish
      data_template:
        topic: "milight/0x0001/rgb_cct/2"
        payload_template: >
          {{ trigger.payload }}
    - service: mqtt.publish
      data_template:
        topic: "milight/0x0001/rgb_cct/3"
        payload_template: >
          {{ trigger.payload }}
    - service: mqtt.publish
      data_template:
        topic: "milight/0x0001/rgb_cct/4"
        payload_template: >
          {{ trigger.payload }}

Now if I press on/off on group 2 of my physical remote, I see that happening in the MQTT explorer and i see the forward automation triggering. All states of 0x1/rgb_cct changes to off/on.

However, Nothing gets updated on Home Assistant. States changes are not registered/pulled back to home assistant

image

kingnlfung commented 2 years ago

facepalm

For anyone that comes across this in the future.

I hardcoded all my devices in HASS with 0x0001, 0x0002 and onwards. In mqtt the 0x0001 gets trimmed to 0x1. For HASS 0x0001 hard coded in config != 0x1, therefore no feedback.

I changed config to 0x1, bam all changes by ESPMH and physical remote are changed back.