sidoh / esp8266_milight_hub

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

JSON Output for Home Assistant #773

Closed poudenes closed 1 year ago

poudenes commented 2 years ago

The MQTT Light config in Home Assistant has been changed/improved. https://www.home-assistant.io/integrations/light.mqtt/

They use follow JSON Schema:

{ "brightness": 255, "color_mode": "rgb", "color_temp": 155, "color": { "r": 255, "g": 180, "b": 200, "c": 100, "w": 50, "x": 0.406, "y": 0.301, "h": 344.0, "s": 29.412 }, "effect": "colorloop", "state": "ON", "transition": 2, }

Thats different then Milight_hub sends. Im not technical enought to understand the difference, but it seems there is a mismatch...

Can you look into this?

poudenes commented 1 year ago

It seems there is a really mismatch. Im try now 1000 different settings but none show JSON output as above how HA thinks its sending by bulb.

poudenes commented 1 year ago

For example: HS Color (hue) To use a light with hue+saturation as the color model, set supported_color_modes to ["hs"] in the platform configuration:

mqtt:
  light:
    - schema: json
      name: mqtt_json_hs_light
      state_topic: "home/light"
      command_topic: "home/light/set"
      color_mode: true
      supported_color_modes: ["hs"]

HA expect:

{
  "state": "ON",
  "color_mode": "hs",
  "color": {
    "h": 24.0,
    "s": 100.0
  }
}

Milight Hub output:

{
   "state":"ON",
   "brightness":237,
   "hue":291,
   "saturation":9
}

So HA doesn't see the HS color and doesn't see the saturation.

devax commented 1 year ago

Sorry for piggybacking, but my problem seems somehow related. Home Assistant is pushing me to update my manual configuration that is currently under

light:
  platform: mqtt
  ...

to the new format which should be

mqtt:
  light:
    ....

The wiki seems to be outdated, as it still shows the legacy configuration (which seems to be unsupported with the upcoming version 2022.12): https://github.com/sidoh/esp8266_milight_hub/wiki/HomeAssistant#hass

Can I find somewhere a working example for the new configuration?

My confusion starts when trying to setup the new configuration in VS Code, as it's giving me a lot of red lines: image

I would appreciate if someone could point me to a good starting guide or to a working example.

Or is this new configuration not supported by milight hub?

poudenes commented 1 year ago

To help you out (offtopic of this whole issue):

this is how I did setup

mqtt:
  light:
    - name: "Balcony All"
      unique_id: "2b23416c-0030-4d99-af4d-99b8d8cf78ad"
      command_topic: "milight/0xAAA4/rgb_cct/1"
      state_topic: "milight/states/0xAAA4/rgb_cct/1"
      schema: "json"
      availability_topic: "milight/client_status"
      payload_available: "connected"
      payload_not_available: "disconnected"
      brightness: true
      effect: true
      effect_list: ["night_mode","white_mode","0","1","2","3","4","5","6","7","8"]
      rgb: true
      color_temp: true
      max_mireds: 370
      min_mireds: 153
      retain: false
      optimistic: true