autoSteve / acMqtt

CBus Automation Controller: Home Assistant, MQTT, Philips Hue and more (for the SHAC/NAC/AC2/NAC2)
GNU General Public License v3.0
14 stars 6 forks source link

Sensors from the lights application sending state #25

Closed vworp closed 6 months ago

vworp commented 7 months ago

Not sure if this is working as intended:- I have a group address under the lighting application, which sets a level based upon what the current security mode is. (I don't know why I did it this way, it was a while ago). If I define this as :- MQTT, sensor, pn=SecurityMode I get a sensor device in Home Assistant. When I change security modes, I can see a MQTT message with the correct level being sent out with an additional STATE value. Looks like Home Assistant is only tracking the STATE value in the payload.

autoSteve commented 7 months ago

Quite right, @vworp. Sensors were broken for the lighting app.

Committed a change to use /level instead for all sensor types, whether lighting, user param or measurement. It makes far more sense to be consistent.

You might like to kill off the cbus/read/ topics using MQTT explorer to clean up the old /state topics for user params/unit params/measurement if you use those. No harm leaving them there, but if you're like me then I know that you will. 😉

Let me know how you go.

autoSteve commented 7 months ago

(And also a commit to be able to use decimal and scale adjustments with lighting group sensors.)

autoSteve commented 7 months ago

A sensor value from a lighting group is going to be exposed as a number, so you probably want to add dec=0 to the keywords. (Actually I'm going to implement no decimals by default for lighting group sensors, as that makes sense for all cases where a scale= keyword is not used.) - default of zero decimals for lighting group is committed.

But a follow-up question for you, @vworp.

How will this be used in HA? Do you want a number? Or would you prefer to see text like 'Armed', 'Disarmed', etc.?

If text would be more helpful (i.e. you're not using the sensor in HA automations), then I could implement something like 'translate=0:Disarmed/1:Armed/2:Some other state'

autoSteve commented 7 months ago

I added the capability to display a lighting group sensor as text anyway, @vworp, using a lvl= keyword.

MQTT, sensor, sa=Family room, pn=Alarm state, lvl=Disarmed:0/Armed:1,

vworp commented 7 months ago

For me, in HA, I'll probably be using just the number. I do like the idea of translating the number to readable text though, so I'll probably mess with both for a while until I'm told to stop breaking things. I think I'm afk for a couple of days, but I should be able to try this out by the weekend

autoSteve commented 7 months ago

Oh please tell me you'll be asking Google or Alexa the state of the alarm over and over, with your significant other listening with more than a roll-eyes... ("But, It's IMPORTANT, darling...")

vworp commented 7 months ago

Essentially, yes :) I, accidentally, utterly destroyed any Alexa commands that worked a few weeks ago. She's not amused, it's on my list to fix. She's moderately pleased that she can turn lamps on and off again now.

vworp commented 6 months ago

I've had a mess around, and sensors are now reporting levels correctly and the level to text looks like it's working perfectly. I didn't even know I wanted that feature, but now it's there, I do :)

autoSteve commented 6 months ago

Brilliant, @vworp. Thanks!