core icon indicating copy to clipboard operation
core copied to clipboard

Change unit of measurement in The Things Network sensors and TTN device tracker compatibility

Open Emacee opened this issue 1 year ago • 6 comments

The problem

The sensors provided by this integration cannot be adjusted in the UI and are therfore incorrectly displayed. I would like to change the unit of measurent of these sensor (e.g. temperature in Celsius in a graph rather than a decimal number in a history bar). Additionally it would be nice to integrate the device_tracker as well; one of the sensors provided by this integration includes the latitude and longitude of the device. I'm struggling to get this working over MQTT as JSON template but I would make sense to take this straight from the TTN API rather than using MQTT as well.

What version of Home Assistant Core has the issue?

core-2024.6.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

thethingsnetwork

Link to integration documentation on our website

https://www.home-assistant.io/integrations/thethingsnetwork/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Emacee avatar Jun 24 '24 12:06 Emacee

Hey there @angelnu, mind taking a look at this issue as it has been labeled with an integration (thethingsnetwork) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of thethingsnetwork can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign thethingsnetwork Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


thethingsnetwork documentation thethingsnetwork source (message by IssueLinks)

home-assistant[bot] avatar Jun 24 '24 12:06 home-assistant[bot]

Let us split this into 2 feature requests:

  • tracker devices
  • unit of measurement

For the last one this was already reported: https://github.com/home-assistant/core/issues/120308

angelnu avatar Jun 25 '24 01:06 angelnu

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Hi there. Im keen to see the Unit_of_measurement resolved so that data coming in via this integration can be displayed correctly in graphs. Why carnt the UoM be an attribute in the setup of either the History Graph Card Config OR more natively with each sensor entity.? following pic for eg HA_Boxy_graph_config with entities

mal62 avatar Sep 26 '24 21:09 mal62

I'd love to see this added too :)

Bassadin avatar Sep 27 '24 09:09 Bassadin

Stumbled upon the same issue with decimal values being handled as text from a temperature sensor. Would also appreciate the possibility to change the data type.

johncliffton avatar Oct 13 '24 10:10 johncliffton

Count me in. The integration is useless without the correct datatypes.

To say that is a bit disrespectful to the developer, imho. But it'd certainly be more usable with them.

Bassadin avatar Nov 05 '24 07:11 Bassadin

I'd like to join the hypetrain for adjustable units of measurement before the issue auto-closes once again.

Zickezack avatar Jan 13 '25 08:01 Zickezack

Another upvote for having units available with the sensor data. Is there any known workaround to allow the TNN network integration data to be shown on a graph?

87yj avatar Feb 16 '25 15:02 87yj

Another upvote for having units available with the sensor data. Is there any known workaround to allow the TNN network integration data to be shown on a graph?

AFAIK no. Probably can be changed with a helper/template in HO. But I have not had time to investitage this yet.

johncliffton avatar Feb 16 '25 17:02 johncliffton

Bonjour @Bassadin @angelnu @87yj @Emacee @mal62

As a workaround, I did modify my configuration.yaml to reference a new file called customize.yaml (I try to keep my configuration.yaml clean) as explained in the documentation: manual customization

configuration.yaml

# Loads default set of integrations. Do not remove.
default_config:

homeassistant:
  customize: !include customize.yaml

Then in the new customize.yaml file, for each sensor I change the properties like device_class, state_class, icon, unit_of_measurement as explained here: https://www.home-assistant.io/integrations/homeassistant/#editing-entity-settings-in-yaml :

exemple for one of my lorawan device: customize.yaml

#-----------------------------------------------
#Sensor lsn50v2_s31
#-----------------------------------------------
sensor.lsn50v2_s31_tempc_sht31:
  state_class: measurement
  device_class: temperature
  unit_of_measurement: "°C"

sensor.lsn50v2_s31_hum_sht31:
  state_class: measurement
  device_class: humidity
  unit_of_measurement: "%"

sensor.lsn50v2_s31_batv:
  state_class: measurement
  device_class: voltage
  unit_of_measure: "V"

hope this help

pmillart avatar Mar 03 '25 15:03 pmillart

Bonjour @Bassadin @angelnu @87yj @Emacee @mal62

As a workaround, I did modify my configuration.yaml to reference a new file called customize.yaml (I try to keep my configuration.yaml clean) as explained in the documentation: manual customization

Hi @pmillart,

I just tried your customization-workaround and it works. Thank you!

johncliffton avatar Mar 05 '25 12:03 johncliffton

Very nice that this works! But still hoping on an integration into the package as with my 11 and growing collection of LoRa sensors, it would be a quality of life improvement.

Zickezack avatar May 15 '25 08:05 Zickezack

Salut @pmillart perfect workaround, merci beaucoup ;)

Image

rschitz avatar May 29 '25 11:05 rschitz

Unfortunately it seems the only way is to extend the payload formatter to include the unit_of_measurement field, right?

Specifically for the device @pmillart has, this file would need to be changed: https://github.com/TheThingsNetwork/lorawan-devices/blob/master/vendor/dragino/lsn50v2-s31.js

Which unfortunately would not help me with my devices (same manufacture, different model: Dragino LHT65). I'm not sure if there's a way to do it more generally.

RexBelli avatar May 30 '25 01:05 RexBelli

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.