mysensors / NodeManager

Plugin for a rapid development of battery-powered sensors
130 stars 82 forks source link

best way to set units via V_UNIT_PREFIX ? #492

Closed zerog2k closed 4 years ago

zerog2k commented 4 years ago

Hello, I have nodemanager sketch using SensorSoilMoisture with Home Assistant, and would like to "hint" that the units are in "%", such that HA displays the history graphs correctly (timeseries rather than some strange bar-graph series for what HA thinks is some unit-less value). From mysensors/ha docs, seems that we do this by sending the units as some V_UNIT_PREFIX.

So looking for the suggestion on best pattern for sending V_UNIT_PREFIX, per https://www.home-assistant.io/integrations/sensor.mysensors/#mysensors-2x-example-sketch

I think that I just need to get the node's child id, and then send() that at least once, but not exactly sure how to do this. Perhaps this should actually be in SensorSoilMoisture ? (i.e. send units as % ?)

zerog2k commented 4 years ago

PR #342 touches on this, but never provides a resolution to it

user2684 commented 4 years ago

You have a point, so far V_UNIT_PREFIX has not been implemented consistently across the sensors. I'd figure out a way to give the ability to set the unit prefix for each child so that NodeManager will take care of it. Will probably take a while since not necessarily an easy one. Unfortunately I do not have a decent workaround. But I'm wondering if you can add a custom hook which aritifically sends the prefix

user2684 commented 4 years ago

Fixed by #517. See PR for implementation details.