sidoh / esp8266_milight_hub

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

Sending color_temp update results in a slightly lower value than set #702

Closed Zer0x00 closed 3 years ago

Zer0x00 commented 3 years ago

Describe the bug

When sending an update to color_temp via MQTT or HTTP it results sometimes in a slightly lower value. If you've set 345 it will become 344. If you've set 360 it will become 359 and so on.

//Edit: Not directly related to this topic but why are MQTT updates for hue & saturation sent when ColorTemperature is updated?

Steps to reproduce

PUT request to http://milight-hub/gateways/0x1/fut089/2 with the following body:

{
  "color_temp": 345
}

Expected behavior

If you've set color_temp = 345 it should be and stay 345.

Setup information

Firmware version

1.10.6 (nodemcuv2)

Output of http://milight-hub.local/about

{"firmware":"milight-hub","version":"1.10.6","ip_address":"192.168.0.101","reset_reason":"External System","variant":"nodemcuv2","free_heap":16272,"arduino_version":"2_4_2","queue_stats":{"length":0,"dropped_packets":0}}

Output of http://milight-hub.local/settings

{"admin_username":"","admin_password":"","ce_pin":4,"csn_pin":15,"reset_pin":0,"led_pin":-2,"radio_interface_type":"nRF24","packet_repeats":100,"http_repeat_factor":1,"auto_restart_period":0,"mqtt_server":"192.168.0.100:1883","mqtt_username":"","mqtt_password":"","mqtt_topic_pattern":"milight/:hex_device_id/:device_type/:group_id","mqtt_update_topic_pattern":"","mqtt_state_topic_pattern":"milight/states/:hex_device_id/:device_type/:group_id","mqtt_client_status_topic":"","simple_mqtt_client_status":true,"discovery_port":48899,"listen_repeats":3,"state_flush_interval":10000,"mqtt_state_rate_limit":1000,"mqtt_debounce_delay":500,"packet_repeat_throttle_sensitivity":0,"packet_repeat_throttle_threshold":200,"packet_repeat_minimum":3,"enable_automatic_mode_switching":false,"led_mode_wifi_config":"Fast toggle","led_mode_wifi_failed":"On","led_mode_operating":"Off","led_mode_packet":"Off","led_mode_packet_count":3,"hostname":"","rf24_power_level":"MAX","rf24_listen_channel":"HIGH","wifi_static_ip":"192.168.0.101","wifi_static_ip_gateway":"192.168.0.1","wifi_static_ip_netmask":"255.255.255.0","packet_repeats_per_loop":3,"home_assistant_discovery_prefix":"","wifi_mode":"n","default_transition_period":500,"rf24_channels":["MID"],"device_ids":[1,2,3,4],"gateway_configs":[],"group_state_fields":["state","brightness","mode","color_temp","bulb_mode","computed_color"],"group_id_aliases":{"Küche":["fut089",1,3],"Schlafzimmer":["fut089",1,2],"Wohnzimmer":["fut089",1,1],"Wohnzimmer Ambiente":["fut089",4,1],"Wohnzimmer LED":["fut089",2,1],"Wohnzimmer Spots":["fut089",3,1],"Şark Köşesi":["fut089",1,4]}}
sidoh commented 3 years ago

I recognize that this is confusing and might have some undesirable behavior, but I expect this to be happening.

Under the hood, Milight's protocol uses a 0-100 scale which is not 1:1 with mireds. That's how the state is being recorded. It's translated into mireds dynamically if that's how state is configured.