JustJoostNL / F1MV-Lights-Integration

The best way to connect your smart home lights to MultiViewer.
https://f1mvli.jstt.me
GNU General Public License v3.0
24 stars 9 forks source link

Ability to publish MQTT events #38

Closed unreal4u closed 1 year ago

unreal4u commented 1 year ago

Hi!

Thanks for this project, I find it utterly fantastic and allows me to make my home work for me for a change :)

That being said, the idea was born from a niche-case but after giving it some thought I believe this might benefit more people.

As context, I have build myself a 5 (pixels) x 6 (pixels) binary clock recently and integrated it with Home Assistant. I want to use this LED matrix to show the flags during a race, since how it is set up is kind of ideal for it!

I can configure it without issues in Home Assistant, but I need some way of telling it that I am watching a race. Instead of me having to go to Home Assistant and enabling a toggle each time, I was thinking of reading out a calendar, but this will not work when I watch a race out of sync (which can happen sometimes).

Since F1MV-Lights-Integration will be responsible for controlling the lights, would it be possible to add MQTT integration so that on application initialization it sends out a signal so I can switch the toggle automatically, while if I kill the application, it will send out a will message so that I can toggle the switch off again?

That in itself is not the main benefit though: I believe that if you can publish other events such as flag states it will leave the door open for basically do anything you want: like if a race has been red-flagged, you might be able to detect this and turn on the coffee machine for example, or in the case of a safety car ending, announce it on all speakers in the house (My wife will surely love this! haha)

I believe other projects similar to mine (I believe the Ulanzi clock) might also benefit from this integration, because since MQTT is kind of universal, you can basically do whatever you want with it so I think it would be a good addition overall.

JustJoostNL commented 1 year ago

Hey @unreal4u! What do you mean exactly with enabling a toggle in Home Assistant each time the race start? Why wouldn't it work without that toggle?

unreal4u commented 1 year ago

Hi @JustJoostNL :

I expressed myself incorrectly there: I meant that you can send the status of your application to MQTT.

In my case it would be useful to signal the clock to stop being a clock and start being a flag screen instead. Otherwise it will show the flag and 1/10 of a second later it will switch back to the clock-mode.

That is why I need a way of knowing whether I've started the application and when I close it. If you are going to publish events in MQTT, you might as well send that state (and the will message gets published automatically when you close the app). I could technically do without that, but it's almost no effort to include it anyway.

That being said, it is an industry standard: all IoT devices I know that support MQTT do send a signal to the broker saying that they're online (Shellie / Zigbee2MQTT / Tasmota). I have no WLED device at home to try right now, but probably WLED does this as well (since it is based on Tasmota anyway).

JustJoostNL commented 1 year ago

Alright, I understand now! Will be adding this soon! πŸ˜„

JustJoostNL commented 1 year ago

@unreal4u

image

πŸ‘€ πŸ‘€

JustJoostNL commented 1 year ago

Btw, any (other) specific things that you want to see in the MQTT?

unreal4u commented 1 year ago

That was fast, thanks man!

In regard to any other specific stuff... the only one I can think about is when the static mode "enables" itself, so maybe a special message that transmits we have entered static mode after the TTL? That being said, I don't know how the internals of your application work so I'm not qualified enough to tell you how much complexity that would add, so that decision is really up to you.

Flag states and application initialization / destruction are stuff that I'll be using definitely!

JustJoostNL commented 1 year ago

@unreal4u This is now implemented in v2.2.0! πŸ˜„

unreal4u commented 1 year ago

Great stuff! Thanks :) I already implemented a little automation in Home Assistant that will stop the clock mode and enter flag mode instead (sorry for bad quality but it's almost 1AM and light isn't in abundance right now):

https://youtu.be/DLKrBWTU_tw

For anyone interested, the topic is F1MV-Lights-Integration/# :)