sparten11740/allmylights

Publish status to mqtt

HydrelioxGitHub opened this issue ยท 9 comments

Hello,

I've managed to control one of my OpenRgb light through a mqtt topic. It goes from a source to a sink like said in the documentation. But if I change a color directly form OpenRgb gui, is there a way to publish on the mqtt broker that light state has changed ?

Hey @HydrelioxGitHub I thought about your use case before and it's a good fit. To reframe it in my words: You are looking for an OpenRGB source to forward values to your MQTT broker. At the moment allmylights only supports OpenRGB sinks.

There's 2 reasons I didn't implement this yet:

  1. The implementation requires constantly polling the OpenRGB server as there is no push based extension point such as web sockets.
  2. Personally I didn't have the use case and knew of no one who wanted to use it that way.

Since 2 is not valid anymore, I will start implementing a solution within the next days. Can't promise to finish it before the weekend tho.

Thank you for the input and keep 'em good ideas coming ;)

PS: Will leave this issue open until a solution is provided

I'm very pleased by your message. If I can help you in some way (with my small skills), don't be afraid to ask !

I'm currently testing a setup with Home Assistant. Maybe, when it will be good enough, I could publish it to your wiki project.

For now, I can choose a color in the Home Assistant UI and the device will reflect the color chosen. I still have several issues (this one is an example...)

@HydrelioxGitHub A contribution in the wiki on your Home Assistant integration would be very welcome :)

@HydrelioxGitHub what's the color format that you'd want to consume in an MQTT message? a hex string such as #FF0066? Asking so I can add a good example

@HydrelioxGitHub what's the color format that you'd want to consume in an MQTT message? a hex string such as #FF0066? Asking so I can add a good example

For my usecase in Home Assistant, the best color format will be a string separated with comma with rgb values in it. ( Ex : 255,0,127 ) This format will work 'out of the box' as mentionned in the documentation : https://www.home-assistant.io/integrations/light.mqtt/#rgb_state_topic

@HydrelioxGitHub I created a new release and a wiki article on how to use an OpenRGB source with an MQTT sink. Let me know if you run into any issues ;)

Thank you for your work. Thanks to the new source and sink, I can have an update on my Home Assistant UI even if the color is changed by OpenRGB itself.

I'm having a minor issue : could I configure a sink that consume a specific source and not the other ?
Because now in my conf file, I have OpenRGB as a sink and a source at the same time. So OpenRGB is trying to consume values produced only for a mqtt sink ( eg : "120,120,120").

So I have some errors on my logs.

2021-03-28 03:56:19 (INFO): OpenRGB device color changed
2021-03-28 03:56:19 (DEBUG): Expression received value System.Collections.Generic.Dictionary`2[System.String,AllMyLights.Connectors.Sources.OpenRGB.DeviceState]
2021-03-28 03:56:19 (DEBUG): Expression returned value 255,0,255
2021-03-28 03:56:19 (DEBUG): Decoding color from 255,0,255
2021-03-28 03:56:19 (INFO): 255,0,255 is no valid hex-code.
2021-03-28 03:56:19 (ERROR): 255,0,255 cannot be a valid color name
2021-03-28 03:56:19 (DEBUG): Received payload ff00ff
2021-03-28 03:56:19 (DEBUG): Decoding color from ff00ff
2021-03-28 03:56:19 (DEBUG): Decoded Color [A=255, R=255, G=0, B=255]
2021-03-28 03:56:19 (INFO): Changing color to Color [A=255, R=255, G=0, B=255]
2021-03-28 03:56:19 (INFO): Found 1 devices to update
2021-03-28 03:56:19 (DEBUG): No override for device ASUS Aura Motherboard found

could I configure a sink that consume a specific source and not the other

Another good point. I've been trying to conceptually explore this for a while and have some solutions in mind. Would also be interested in your thoughts on those or if you can maybe even think of something better. Will open another issue to track progress on the topic. (As is, this is not possible at the moment)

@HydrelioxGitHub Added the issue. Personally I think I am in favour of option 1. But I don't really have a strong opinion on it (and maybe you can even think of something better)