Change unit of measurement in The Things Network sensors and TTN device tracker compatibility
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
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 closeCloses the issue.@home-assistant rename Awesome new titleRenames the issue.@home-assistant reopenReopen the issue.@home-assistant unassign thethingsnetworkRemoves the current integration label and assignees on the issue, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-informationRemove 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)
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
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
I'd love to see this added too :)
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.
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.
I'd like to join the hypetrain for adjustable units of measurement before the issue auto-closes once again.
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?
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.
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
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!
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.
Salut @pmillart perfect workaround, merci beaucoup ;)
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.
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.