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

[Feature request] Deduct unit from metric name and apply unit to value. #222

Open
TheChatty opened this issue Apr 30, 2023 · 2 comments
Open

Comments

@TheChatty
Copy link

TheChatty commented Apr 30, 2023

Current implementation of sensor.py is trying to match exact metric name to predefined list. If it matches a preconfigured unit is applied. All other metrics have no unit at all.

To keep the current JSON format compatible I vote for a naming pattern like "%%". This (or a similar) pattern could easily be provided in the JSON payload by SMI.

sensor.py would need to subtract "%%" from the metrics name and apply the according unit the value.

My Tasmota installation reads three meters and provides their readings like this:

{
  "Time": "2023-04-30T15:48:46",
  "Strom": {
    "P_in%%W": 998.34,
    "L1%%W": 4.29,
    "L2%%W": 645.19,
    "L3%%W": 348.86,
    "E_in%%kWh": 20687.329,
    "E_out%%kWh": 0
  },
  "SekHK": {
    "Temp_Outside%%°C": 13,
...
@SteveDinn
Copy link

I think having two values, Temp_Outside and Temp_Outside_Unit would be better. It's weird to have to parse a value name.

{
  "Time": "2023-04-30T15:48:46",
  "SekHK": {
    "Temp_Outside": 13,
    "Temp_Outside_Unit": "°C"
   }
}

@TheChatty
Copy link
Author

TheChatty commented Apr 30, 2023

With my solution I had code size, RAM and network impact in mind. Two k/v pairs per metric is a much cleaner approach of course but has less likelihood of being merged into Tasmota.

I'd be ok with either solution as long as this dreaded problem (measurements without units) is resolved.

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

No branches or pull requests

2 participants