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

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

Open
emteedubs opened this issue Oct 11, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@emteedubs
Copy link

emteedubs commented Oct 11, 2020

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:

  • Last rebooted
  • Location
  • Last changed

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
Copy link
Owner

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

Regards

@Odianosen25 Odianosen25 added the enhancement New feature or request label Nov 2, 2020
@Odianosen25
Copy link
Owner

@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
Copy link
Author

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
Copy link

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.

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

No branches or pull requests

3 participants