sidoh / esp8266_milight_hub

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

Bonjour name milight-hub.local hardcoded? #740

Open normen opened 2 years ago

normen commented 2 years ago

Describe the bug

When setting up multiple milight-hub devices in a network and assigning different hostnames the hubs can be accessed by their hostnames but when trying to access the hub via the milight-hub.local address there seems to be a clash where a random device on the network answers.

It seems that the milight-hub.local address for Bonjour is always the same and not based on the hostname property.

Steps to reproduce

Start multiple milight-hub devices and connect them to a single network. Try to access a specific device via the milight-hub.local address.

Expected behavior

The Bonjour address of the milight-hub should be based on the given hostname.

Setup information

Milight-hubs on D1Mini as well as NodeMCU devices.

Firmware version

1.10.7

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

{"firmware":"milight-hub","version":"1.10.7-1-ge53f5ce","ip_address":"192.168.2.82","reset_reason":"External System","variant":"nodemcuv2","free_heap":14952,"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":50,"http_repeat_factor":1,"auto_restart_period":0,"mqtt_server":"homebridge","mqtt_username":"","mqtt_password":"","mqtt_topic_pattern":"studio/:device_id/:device_type/:group_id","mqtt_update_topic_pattern":"","mqtt_state_topic_pattern":"","mqtt_client_status_topic":"","simple_mqtt_client_status":false,"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":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":"Slow blip","led_mode_packet":"Flicker","led_mode_packet_count":3,"hostname":"milight-hub-studio","rf24_power_level":"LOW","rf24_listen_channel":"MID","wifi_static_ip":"","wifi_static_ip_gateway":"","wifi_static_ip_netmask":"","packet_repeats_per_loop":10,"home_assistant_discovery_prefix":"","wifi_mode":"n","default_transition_period":500,"rf24_channels":["LOW","MID","HIGH"],"device_ids":[4624,5725,15780,19234],"gateway_configs":[],"group_state_fields":["state","brightness","mode","color_temp","bulb_mode","computed_color"],"group_id_aliases":{"Aufnahmeraum_1":["rgb_cct",15780,1],"Aufnahmeraum_2":["rgb_cct",15780,2],"Aufnahmeraum_3":["rgb_cct",15780,3],"Aufnahmeraum_4":["rgb_cct",15780,4],"Aufnahmeraum_alle":["rgb_cct",15780,0],"Bewegungsraum_1":["rgb_cct",4624,1],"Bewegungsraum_2":["rgb_cct",4624,2],"Bewegungsraum_3":["rgb_cct",4624,3],"Bewegungsraum_4":["rgb_cct",4624,4],"Bewegungsraum_alle":["rgb_cct",4624,0],"Regieraum_1":["rgbw",19234,1]}}

Additional context

sidoh commented 2 years ago

Hey @normen, you're correct, it's hardcoded. It does make sense for it to be a function of hostname.

I hesitate a little bit to change behavior like this in case existing users happen to be relying on it, but in this case that seems somewhat unlikely.

If you want to take a stab at the change, it should be pretty straightforward:

  1. mDNS is set up here
  2. The configured hostname should be available through settings.hostname (source)