Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domoticz 2024.7 fails with v1.13 #854

Open
sincze opened this issue Nov 24, 2024 · 35 comments
Open

Domoticz 2024.7 fails with v1.13 #854

sincze opened this issue Nov 24, 2024 · 35 comments
Labels

Comments

@sincze
Copy link

sincze commented Nov 24, 2024

Describe the bug

Domoticz Mi-Lights discovered via auto discovery do not respond correctly anymore.
Colors can not be changed / brightness does not respond

Steps to reproduce

Install latest version of the bridge software.

Expected behavior

Domoticz should be able to control the lights as with pre FW versions.

Setup information

Firmware version

1.13

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

"{
"firmware": "milight-hub",
"version": "1.13.0",
"ip_address": "192.xxx.xxx.xxx",
"reset_reason": "Software/System restart",
"variant": "d1_mini",
"free_heap": 14368,
"arduino_version": "3.1.2",
"free_stack": 1168,
"flash_used": 11797,
"flash_total": 957314,
"flash_pct_free": 98,
"mqtt": {
"configured": true,
"connected": true,
"status": "Connected"
},
"queue_stats": {
"length": 0,
"dropped_packets": 0
}
}"

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

{
	"admin_username": "idonot",
	"admin_password": "wanttosharethis",
	"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": "mqtt.myserver.lan:1883",
	"mqtt_username": "top",
	"mqtt_password": "secret",
	"mqtt_topic_pattern": "milight/commands/:device_id/:device_type/:group_id",
	"mqtt_update_topic_pattern": "",
	"mqtt_state_topic_pattern": "milight/state/: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": "milight-discovery",
	"wifi_mode": "n",
	"default_transition_period": 500,
	"rf24_channels": [
		"LOW",
		"MID",
		"HIGH"
	],
	"device_ids": [
		2651,
		51994
	],
	"gateway_configs": [
		[
			51994,
			8899,
			5
		],
		[
			2651,
			8898,
			5
		]
	],
	"group_state_fields": [
		"state",
		"brightness",
		"computed_color",
		"mode",
		"color_temp",
		"color_mode",
		"status"
	]
}"

Additional context

I noticed the commands seems to have changed a bit:
from:

{
	"state": "ON",
	"brightness": 255,
	"color": {
		"r": 255,
		"g": 255,
		"b": 255
	},
	"color_mode": "brightness",
	"status": "ON"
}

To:

{"state":"ON","color":{"r":255,"g":136,"b":100}}
{"state":"ON","brightness":148}

{"state":"ON","color":{"r":255,"g":255,"b":255}}

@sincze sincze added the bug label Nov 24, 2024
@sincze sincze changed the title Domoticz Fails with v1.13 Domoticz 2024.7 fails with v1.13 Nov 24, 2024
@sidoh
Copy link
Owner

sidoh commented Nov 24, 2024

Hello! The backend changes in 1.13 are pretty limited and shouldn't cause any issues like this. Can you try downgrading to 1.12 and see if it still works?

State output shouldn't be any different as long as your config hasn't changed.

I don't use domoticz, so hard for me be super helpful here. Happy to fix anything that's broken, but might need a hand isolating the issue.

@sincze
Copy link
Author

sincze commented Nov 25, 2024

Hello! The backend changes in 1.13 are pretty limited and shouldn't cause any issues like this. Can you try downgrading to 1.12 and see if it still works?

State output shouldn't be any different as long as your config hasn't changed.

I don't use domoticz, so hard for me be super helpful here. Happy to fix anything that's broken, but might need a hand isolating the issue.

Thanks for the reply.
I noticed at least the following is missing in 1.13 in autodiscovery topic:

"brightness": true,
"rgb": true,
{
	"dev_cla": "light",
	"schema": "json",
	"name": "Lampje Spare",
	"cmd_t": "milight/commands/0xAX2D/rgbw/4",
	"stat_t": "milight/state/0xAX2D/rgbw/4",
	"uniq_id": "CC8789-Lampje Spare",
	"dev": {
		"name": "milight-hub",
		"sw": "esp8266_milight_hub v1.13.0",
		"mf": "espressif",
		"mdl": "d1_mini",
		"identifiers": "13404041",
		"cu": "http://192.168.xx.yy"
	},
	"avty_t": "milight/client_status",
	"pl_avail": "connected",
	"pl_not_avail": "disconnected",
	"effect": true,
	"fx_list": [
		"night_mode",
		"white_mode",
		"0",
		"1",
		"2",
		"3",
		"4",
		"5",
		"6",
		"7",
		"8"
	],
	"sup_clrm": [
		"rgb"
	]
}

@sidoh
Copy link
Owner

sidoh commented Nov 25, 2024

Ah, this was actually a change in 1.12. Unfortunately it was necessary to fix compatibility issues with HomeAssistant. Does Domoticz keep this up to date?

@sincze
Copy link
Author

sincze commented Nov 26, 2024

Ah, this was actually a change in 1.12. Unfortunately it was necessary to fix compatibility issues with HomeAssistant. Does Domoticz keep this up to date?

Depends on definition of 'keeps this up 2 date' I guess.
Is autodiscovery a documented process ??

Hence why ' deprecated ' was shown in HA ?

I raised: domoticz/domoticz#6214, however I do not have the knowledge to explain what needs to be changed.

@sidoh
Copy link
Owner

sidoh commented Nov 26, 2024

Yeah, it's documented reasonably well. It's just not really a standard -- just something HomeAssistant came up with.

https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery
https://www.home-assistant.io/integrations/light.mqtt/

It's probably best that I follow HomeAssistant's changes, but would happily add more specific support for other automation platforms.

@sincze
Copy link
Author

sincze commented Nov 26, 2024

Interesting.

According to: https://wiki.domoticz.com/MQTT#Add_hardware_%22MQTT_Auto_Discovery_Client_Gateway%22

It states "From Stable 2022.1 Domoticz MQTT supports Home assistant MQTT Discovery".
However if I understand this correctly since 2022 auto discovery was slightly changed in Homeassistant, as such the hub code was adjusted.

With the new FW Homeassistant works indeed with the HUB and the Milights..
However due to some missing params in the JSON Domoticz is unable to control and or create the correct Devices using their autodiscovery code.

That basically sums up the issue ;-)

image

So basically with the new FW the devices are recognized as regular switch (ON/OFF)
There are no RGBW and DIMMING options.

If Domoticz as stated "supports Home assistant MQTT Discovery" it is necessary to update that code. However as the auto-discovery is a generic module (also supporting zigbee2mqtt, zwave-js-ui e.g.) I don't know if that is possible.

As I am using Domoticz & Homeassistant to play with the lights I do not see how adjusting the hub code would be able to support both. (but then again. I am not a developer...)
Under the "State Fields" it would be possible to add a Domoticz entry... that for example publishes the ' old ' discovery message to a separate MQTT topic so that Domoticz will handle these without disturbing Homeassistant (deprecated log) that is published to the regular topic..

What are your thoughts??

@sidoh
Copy link
Owner

sidoh commented Nov 26, 2024

Yeah, if their intention is to be compatible with HomeAssistant's discovery protocol, they're out of date. Fine if they want to treat it as a fork, but probably better to think of it as its own thing at that point.

The issue here isn't with state fields, it's with the discovery client. State fields control which fields are filled out when the hub sends updates about a bulb. The discovery client is what advertises which bulbs exist and what functionality they have. The syntax is different and is hard-coded to fit the HomeAssistant spec.

I think the right thing here -- assuming Domoticz can't update -- is to just copy/paste the HomeAssistant discovery client and make the changes necessary to keep it compatible with Domoticz. Would also need a config to enable.

@sincze
Copy link
Author

sincze commented Nov 27, 2024

The main Developer of Domoticz is looking into it. Improvement has been made.
image

He found the issue, the short code 'sup_clrm' was not implemented, only the full code 'supported_color_modes'

Lights are now discovered as RGB, still looking into the WW part
This is how they were detected back in the day
image

First playaround using these buttons
image

Causes
image

So I need to dive a little bit deeper into that.

Using the slider or selecting colors does not cause an issue. However need to check if the color actually changes. Need to do that tonight.

@gizmocuz
Copy link

If the light supports W or WW, this should be reported in the 'supported_color_modes' like rgbw, rgbww, currently it is advertised as RGB, hence the RGB type creation.

@sidoh
Copy link
Owner

sidoh commented Nov 27, 2024

The main Developer of Domoticz is looking into it. Improvement has been made. image

He found the issue, the short code 'sup_clrm' was not implemented, only the full code 'supported_color_modes'

Lights are now discovered as RGB, still looking into the WW part This is how they were detected back in the day image

First playaround using these buttons image

Causes image

So I need to dive a little bit deeper into that.

Using the slider or selecting colors does not cause an issue. However need to check if the color actually changes. Need to do that tonight.

That's great! He's probably already found it, but here's a full list of supported shortcodes. I normally wouldn't have bothered with these, but the discovery payload was getting quite large and using shortcodes helped quite a bit.

The semantics of supported_color_mode changed over time -- actually quite frustrating how frequently they make breaking changes to the schema of this thing. It's documented here.

A light with RGB and adjustable color temp will have something like "supported_color_modes":["rgb", "color_temp"].

If it's at all helpful, here's the code that fills out the discovery payload: https://github.com/sidoh/esp8266_milight_hub/blob/master/lib/MQTT/HomeAssistantDiscoveryClient.cpp#L123

If the light supports W or WW, this should be reported in the 'supported_color_modes' like rgbw, rgbww, currently it is advertised as RGB, hence the RGB type creation.

As reasonable as this would be, I don't think it's correct. RGBW and RGBWW lights have different behaviors. These are lights where you can adjust the RGB, WW and CW parameters simultaneously. What I described above is how you specify devices like milight where RGB and WW are separate modes.

@sincze
Copy link
Author

sincze commented Nov 27, 2024

Tnx @sidoh for clarifying. I just came home, tested the new code. We are moving forward on the Domoticz side.. I'll keep you informed.

@gizmocuz I can control the Mi-Lights using the API (control means select a color or white, brightness not working):
Random Color:
http://domoticz-test/json.htm?type=command&param=setcolbrightnessvalue&idx=7&color={"m":3,"t":0,"r":68,"g":255,"b":103,"cw":0,"ww":0}&brightness=100
White:
http://domoticz-test/json.htm?type=command&param=setcolbrightnessvalue&idx=7&color={"m":3,"t":0,"r":255,"g":255,"b":255,"cw":0,"ww":0}&brightness=100

Via the Domoticz interface selecting the color works. The vertical slider has no effect on the light.
image

Dimmer has no effect on the light it jumps around if I click 80 it goes to 20 for example
image

Blue On button does not work
Red Off button does work.

@sincze
Copy link
Author

sincze commented Nov 27, 2024

While using Domoticz:

MQTT Explorer shows
Selecting color:
`milight/commands/0xAAAA/rgbw/4
{"color":{"b":95,"g":52,"r":255},"state":"ON"}

milight/state/0xAAAA/rgbw/4
{"state":"ON","brightness":92,"color":{"r":255,"g":0,"b":55},"color_mode":"rgb"}
`

Could it be brightness in Domoticz is 0-100 and from milight
image

0-255 ??

Pressing the Red Off button
milight/commands/0xAAAA/rgbw/4
4 = {"state":"OFF"}

Pressing the Blue On button
milight/commands/0xAAAA/rgbw/4
4 = {"brightness":4}

If Off and on Switching is done through Mi-Light hub interface it changes the following

milight/state/0xAAAA/rgbw/4
{"state":"OFF","brightness":10,"color":{"r":67,"g":0,"b":255},"color_mode":"rgb"}
{"state":"ON","brightness":10,"color":{"r":67,"g":0,"b":255},"color_mode":"rgb"}

it leaves the brightness untouched.

@sidoh
Copy link
Owner

sidoh commented Nov 27, 2024

Yeah, the brightness field is 0..255 (this is what HomeAssistant expects).

You can enable the group state field level which is brightness on a 0..100 scale.

@sincze
Copy link
Author

sincze commented Nov 30, 2024

Did some testing today.
Turned the light on using 220v switch so the light is initially on. (ofcourse then Domoticz does not know the state).

However I can controll the Brightness command and the light responds
Milight-100

Same for 50 percent.
Milight-50

The brightness under state does not change.

milight-colorpick

I can select a color and the bulb responds with the correct color. If I put the brightness slider to 50.. percent I get less.
milight-50-selected

If I control brightness via the Milight Hub itself this is the MQTT and now the bulb is in full brightness.
milight-100-via-hub

Notice the state also changed its brightness to 255.

Changed the brightness via the Milight Hub interface to 50%....
milight-50-selected-via-hub

@sidoh
Copy link
Owner

sidoh commented Nov 30, 2024

I think we'd already figured out what's going on here, right? Domoticz is expecting a 0-100 scale, but the brightness field is 0-255. There's unfortunately not an easy way around this. If I flipped the ranges, it'd break things for HomeAssistant.

If it's possible to use the level field in Domoticz, that is 0-100.

@gizmocuz
Copy link

gizmocuz commented Dec 2, 2024

@sidoh , This has been corrected in the latest version, using the default brightness scale (255) now.

But... it is not advertised that this light supports the brightness field... not as a boolean, or color_mode.

brightness boolean (Optional, default: false)
Flag that defines if light supports brightness when the rgb, rgbw, or rgbww color mode is supported.

supported_color_modes list (Optional)
A list of color modes supported by the list. Possible color modes are onoff, brightness, color_temp, hs, xy, rgb, rgbw, rgbww, white. Note that if onoff or brightness are used, that must be the only value in the list.

@sidoh
Copy link
Owner

sidoh commented Dec 2, 2024

I do set brightness in the supported_color_modes field, but only if the bulb supports neither RGB nor adjustable white. (iirc this doesn't actually apply to any milight bulbs so really there "just in case"):

https://github.com/sidoh/esp8266_milight_hub/blob/master/lib/MQTT/HomeAssistantDiscoveryClient.cpp#L130C1-L134C4

  // should only have brightness in this list if there are no other color modes
  // https://www.home-assistant.io/integrations/light.mqtt/#supported_color_modes
  if (colorModes.size() == 0) {
    colorModes.add(F("brightness"));
  }

I removed the brightness config in the same commit I fixed other HomeAssistant compatibility things:

f320677#diff-ef719a88e000cdc47d752427894614c2c86fd22c257a0da936e5d8c30a6682b6L87

but it's possible that was a mistake. It does seem like that should be set to true, but it has not caused issues with HomeAssistant. I can try changing it back and check if it has any effect on HomeAssistant.

@sincze
Copy link
Author

sincze commented Dec 2, 2024

It seems Team Domoticz @gizmocuz & Team Milight-Hub @sidoh are figuring it out. ;-)
If testing is needed please let me know.

I just found a 1.10.7 (nodemcuv2) Milight-Hub in my cold storage. Running both hubs in Parallel to spot the changes in MQTT Explorer.
The 1.10.7 had a button called Mode (never used it before) but it creates some nice effects on the bulbs.

image

@gizmocuz
Copy link

gizmocuz commented Dec 3, 2024

It seems sending a blue value of 128 vs 255 does not make any difference. If this is the case (probably duo internal color format), we really have to send the brightness separately.

@sidoh , is it possible to make a version with the added brightness support indication?

config[GroupStateFieldNames::BRIGHTNESS] = true;

This should also work in HASS, maybe you could test this before making a new firmware public?

@sincze
Copy link
Author

sincze commented Dec 4, 2024

Ok I'll need to wait for @sidoh before I can continue testing.

@sincze
Copy link
Author

sincze commented Dec 6, 2024

@sidoh , the following can be used in the milight hub without error messages in my HA logfile.
So I think @gizmocuz is correct on being able to add brightness.

{
	"dev_cla": "light",
	"schema": "json",
	"name": "Hal Voordeur",
	"cmd_t": "milight/commands/0xXXX/rgbw/1",
	"stat_t": "milight/state/0xXXX/rgbw/1",
	"uniq_id": "CC8789-Hal Voordeur",
	"dev": {
		"name": "milight-hub",
		"sw": "esp8266_milight_hub v1.13.0",
		"mf": "espressif",
		"mdl": "d1_mini",
		"identifiers": "13404041",
		"cu": "http://192.XXX.XX.XX"
	},
	"avty_t": "milight/client_status",
	"pl_avail": "connected",
	"pl_not_avail": "disconnected",
	"effect": true,
	"brightness": true,
	"fx_list": [
		"night_mode",
		"white_mode",
		"0",
		"1",
		"2",
		"3",
		"4",
		"5",
		"6",
		"7",
		"8"
	],
	"sup_clrm": [
		"rgb"
	]
}

If both entries are here:

  "brightness": true,
  "rgb": true,

The RGB on this location will cause an issue in Homeassistant.
image

if you republish the config without the 'rgb' but including 'brightness' :
image

Instantly it becomes available.

@sincze
Copy link
Author

sincze commented Dec 7, 2024

Adjusting the Brighness no error in HA debug log.

2024-12-07 11:10:47.087 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140732205525040] <USER> from <IP> (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36): Received {'type': 'call_service', 'domain': 'light', 'service': 'turn_on', 'return_response': False, 'service_data': {'entity_id': 'light.milight_hub_lampje_spare', 'brightness_pct': 39}, 'id': 67}

Adjusting Color, no error in HA debug log

2024-12-07 11:13:57.780 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140732205525040] <USER> from <IP> (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36): Received {'type': 'call_service', 'domain': 'light', 'service': 'turn_on', 'return_response': False, 'service_data': {'entity_id': 'light.milight_hub_lampje_spare', 'rgb_color': [255, 110, 84]}, 'id': 72}
2024-12-07 11:13:58.923 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140732205525040] <USER> from <IP> (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36): Sending b'{"type":"event","event":{"c":{"light.milight_hub_lampje_spare":{"+":{"lu":1733566438.9235277,"c":"01JEG9S6CME3DC8VNR0DDP5FNC","a":{"brightness":255,"hs_color":[7.765,100.0],"rgb_color":[255,33,0],"xy_color":[0.693,0.306]}}}}},"id":24}'

@sincze
Copy link
Author

sincze commented Dec 10, 2024

@sidoh , bumb the issue ;-0 any chance that I can assist somewhere to solve this. Now the lights do not work as expected ;-)

I am however a bit lucky as Domoticz allows me to have multiple autodisovery topics so per hardware type.
Milight has its own autodiscovery topic.
Zigbee2mqtt as well
Zwave-js-ui as well.

So not everything needs to be in Homeassistant.

image

So as a temporary workaround I can have 2 separate autodiscovery profiles fro milight.. 1 compatible with Domoticz and 1 forwarded to Homeassistant. However it is a workaround. A fix for the bug would be preferred ;-)

@sidoh
Copy link
Owner

sidoh commented Dec 10, 2024

Apologies for the radio silence. It sounds like all we need to do is set the brightness field in the autodiscovery payload. It'll probably still be a bit before I can test this myself, but I can cut a beta release with this change earlier than that.

If you want to open a PR with the change I can merge it.

@sincze
Copy link
Author

sincze commented Dec 10, 2024

Apologies for the radio silence. It sounds like all we need to do is set the brightness field in the autodiscovery payload. It'll probably still be a bit before I can test this myself, but I can cut a beta release with this change earlier than that.

If you want to open a PR with the change I can merge it.

No problem. Appreciate your help.
Based on the info on this thread (you probably figured it out I am not a developer) I created:
#859

Hope it meets the expected result.

@Jojo-1000
Copy link

For reference, here is what the supported discovery configs are:

https://www.home-assistant.io/integrations/light.mqtt/#json-schema---configuration

brightness boolean (Optional, default: false)
Flag that defines if light supports brightness when the rgb, rgbw, or rgbww color mode is supported.

So that should indeed be set to true.

supported_color_modes list (Optional)
A list of color modes supported by the list. Possible color modes are onoff, brightness, color_temp, hs, xy, rgb, rgbw, rgbww, white. Note that if onoff or brightness are used, that must be the only value in the list.

This should not have brightness in it.

@sincze
Copy link
Author

sincze commented Dec 11, 2024

Ok. If I understand it correctly The proposed pull request #859 should be enough to get things back up and running with the latest Domoticz beta.

@sidoh
Copy link
Owner

sidoh commented Dec 11, 2024

@sincze
Copy link
Author

sincze commented Dec 11, 2024

Ok Installed 1.13.1-beta2 @sidoh , and started testing with @gizmocuz with Domoticz 2024.7 (build 16350)

Removed all previous hardware and RETAINED MQTT Topics.
After that added HARDWARE back to Domoticz:
2024-12-11 19:29:08.809 Status: milight: Discovered: milight-hub (Lampje Spare)/milight-hub (Lampje Spare) (unique_id: CC8789-Lampje Spare) supported_color_modes: { rgb }

{
	"dev_cla": "light",
	"schema": "json",
	"name": "Lampje Spare",
	"cmd_t": "milight/commands/0xXXXX/rgbw/4",
	"stat_t": "milight/state/0xXXXX/rgbw/4",
	"uniq_id": "CC8789-Lampje Spare",
	"dev": {
		"name": "milight-hub",
		"sw": "esp8266_milight_hub v1.13.1-beta2",
		"mf": "espressif",
		"mdl": "d1_mini",
		"identifiers": "13404041",
		"cu": "http://192.xx.xx.xx"
	},
	"avty_t": "milight/client_status",
	"pl_avail": "connected",
	"pl_not_avail": "disconnected",
	"brightness": true,
	"effect": true,
	"fx_list": [
		"night_mode",
		"white_mode",
		"0",
		"1",
		"2",
		"3",
		"4",
		"5",
		"6",
		"7",
		"8"
	],
	"sup_clrm": [
		"rgb"
	]
}

So I can see the brightness is now in the main topic. Let's start testing.
Slider (Dimmer works in Domoticz, however the color selector is not working anymore.
If I click on a color in Domoticz.
2024-12-11 19:42:18.895 Status: setcolbrightnessvalue: ID: 7, bri: 21, color: '{m: 3, RGB: 20ff21, CWWW: 0000, CT: 0}'

@sincze
Copy link
Author

sincze commented Dec 11, 2024

I started testing with the Milight Webinterface: (works color . dimmer white)

White

{
	"state": "ON",
	"brightness": 143,
	"color": {
		"r": 255,
		"g": 255,
		"b": 255
	},
	"color_mode": "brightness"
}

Color

 {
	"state": "ON",
	"brightness": 255,
	"color": {
		"r": 42,
		"g": 255,
		"b": 0
	},
	"color_mode": "rgb"
}

Domoticz Notices the changes:
2024-12-11 19:44:57.889 milight: Color Switch/RGB (milight-hub (Lampje Spare))

@Jojo-1000
Copy link

@sincze The state topic is one-way and only shows the current state. You want to use the command topic to control the lights.

@sincze
Copy link
Author

sincze commented Dec 11, 2024

@sincze The state topic is one-way and only shows the current state. You want to use the command topic to control the lights.

djeez it is so late i make mistakes. thanks for clarifying

@sincze
Copy link
Author

sincze commented Dec 11, 2024

Testing With Domoticz @gizmocuz :

image

Command: {"state":"OFF"}
State:
4 = {"state":"OFF","brightness":20,"color":{"r":255,"g":131,"b":0},"color_mode":"rgb"}
TEST DIMMER = OK, light switches off.

image

Command: 4 = {"brightness":255}
State:
4 = {"state":"OFF","brightness":20,"color":{"r":255,"g":131,"b":0},"color_mode":"rgb"}
TEST = FAILED, Light does not go on!

image

Command: 4 = {"brightness":255,"state":"ON"}
State:
4 = {"state":"ON","brightness":255,"color":{"r":255,"g":131,"b":0},"color_mode":"rgb"}
TEST DIMMER = OK

image

Command: 4 = {"brightness":128,"state":"ON"}
State:
4 = {"state":"ON","brightness":133,"color":{"r":255,"g":131,"b":0},"color_mode":"rgb"}
TEST DIMMER = OK

image

Light becomes white
Command: 4 = {"color":{"b":0,"g":1,"r":3},"state":"ON"}
State:
4 = {"state":"ON","brightness":143,"color":{"r":255,"g":255,"b":255},"color_mode":"brightness"}
TEST FAILED, light turned white.

image

Selected blue color.
Command: 4 = {"brightness":31,"state":"ON"}
State:
4 = {"state":"ON","brightness":31,"color"{"r":255,"g":255,"b":255},"color_mode":"brightness"}
TEST FAILED, no color selected.

image

Selected Red Color
Domoticz log:
2024-12-11 20:21:42.708 Status: setcolbrightnessvalue: ID: 7, bri: 12, color: '{m: 3, RGB: ff171a, CWWW: 0000, CT: 0}'

MQTT Explorer
Command: 4 = {"brightness":31,"state":"ON"}
State:
4 = {"state":"ON","brightness":31,"color":{"r":255,"g":255,"b":255},"color_mode":"brightness"}
TEST FAILED, no color selected.

So I guess something is wrong In Domoticz as it seems not updating the command..
image

Milighthub uses the following preset:
image

@gizmocuz
Copy link

The only problem left is the ON command, Domoticz only sends { "state": "ON" }
I suppose internally you keep track of the last color set? Can this be used when only the ON is received?
What happens when the light is set to green, and the power is disconnected (a physical switch), and connected, I suppose it goes to the last received value (green)?

@sincze
Copy link
Author

sincze commented Dec 29, 2024

@gizmocuz ok switched the light to FULL brightness and switched color to GREEN.
Pressed the red button in Domoticz.
Light Switches OFF
image

Switched off (using the physical 220v switch).
Waited for 30 seconds.
Switched on the physical switch (re applied 220v) light turns on GREEN.

So now Domoticz does not know the light is turned On however that seems logical regarding the protocol in use.

While clicking the ON button in domoticz I noticed:

milight/commands/0xXXX/rgbw/4 {"brightness":255}

@sidoh , If I use the milight-hub to toggle ON the light. It does not produce anything in MQTT topic milight/commands/0xXXX/rgbw/4
The miligh ON / OFF toggle does change the
milight/state/0xXXXX/rgbw/4

{"state":"ON","brightness":255,"color":{"r":42,"g":255,"b":0},"color_mode":"rgb"} 
{"state":"OFF","brightness":255,"color":{"r":42,"g":255,"b":0},"color_mode":"rgb"}

So could it be this is not correctly implemented in Miligh-Hub you think? We would or should expect a command topic if the milight hub is used to swich on/off a lamp?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants