Odianosen25 / Monitor-App

Appdaemon App for Andrew's Monitor Presence Detection System
74 stars 9 forks source link

[Request] Parse MQTT payload msg from Monitor sensor state into state and attributes #66

Open emteedubs opened 3 years ago

emteedubs commented 3 years ago

Right now sensor entities created in HA for each Monitor uses the MQTT payload message verbatim as the state. For example, the state for my "living room" monitor is as follows:

{“last_rebooted”: “”, “location”: “Living Room”, “last_changed”: “2020-10-10T11:38:44-04:00”, “state”: “online”})

It would be great if the sensor would report the state only based on the “state” topic and then maybe have the other topics as attributes.

Using the example above, the sensor.living_room_state would have an “online” state. With attributes:

Also, the overall "Monitor" state can also be converted to a sensor with attributes rather than using the state to store the MQTT payload. This will also eliminate the "More than state max length of 255 characters" error I get with this sensor. This also has a bit more attributes than the individual monitor sensors. For example, this one would have "scan_type", "online_nodes", etc.

Thank you.

Odianosen25 commented 3 years ago

Yes I plan on making the monitors sensors once I got time to work on upgrades. Apologies for the late response.

Regards

Odianosen25 commented 3 years ago

@emteedubs,

I just started looking into this, and noticed that actually there are sensors for what you looking for but in AD and not HA. So you also want this in HA? I am looking at even reducing the number of sensors in HA and focus on AD entities, but if you want it, can also want it but will make it optional.

Do let me know what you think.

Kind regards

emteedubs commented 3 years ago

Sorry @Odianosen25 but I'm not too familiar with how I would interact with the AD entities in HA directly. If there's a way for me to access the info of those AD entities from HA, I think that would be okay. Otherwise I think having the option to enable those sensors in HA would be helpful for those who work mainly in HA and not as familiar with how to interact with AD entities.

mariwing commented 3 years ago

Just a tip; this could be quite easily setup with custom mqtt sensors. I have these two:

 - platform: mqtt
    name: Monitor System state
    state_topic: monitor/state
    value_template: "{{ value_json.state }}"
    json_attributes_topic: monitor/state
 - platform: mqtt
   name: Monitor Node1 state
   state_topic: bms/node1/state
   value_template: "{{ value_json.state }}"
   json_attributes_topic: bms/node1/state

You will then get two sensors, one for the entire system and one for the "node 1" scanning device. All information that is posted to MQTT is available as attributes on these two sensors.

I realize that you asked for this to come directly from AD so you won't need to create them manually but this is a work around if you like to get it up and running yourself.