Need helt converting ºF to ºC on sensor

Hi there.

I live in Scandinavia and therefor of course use celsius as unit of measurement.

Well, i have a batch of sensors from ebay that send data as fahrenheit, but say it is celsius.
Like this:

This is hos my configuration in configuration.yaml looks like:

Sensor:

  • platform: rfxtrx
    automatic_add: True
    devices:
    0a52090748008277190269:
    name: rfxtrx_ukjent_6
    data_type:
    - Temperature

  • platform: template
    sensors:
    rfxtrx_ukjent_6:
    unit_of_measurement: °C
    value_template: “{{ (states.sensor.rfxtrx_temp.state | float - 32) * (5/9) }}”

But this is what the output looks like:

What is wrong here?

try:

{{ (states.sensor.rfxtrx_ukjent_6_temperature.state | float - 32) * (5/9) }}

Is that really reading -62.9 degrees Fahrenheit? That’s freakin’ cold!

Change unit_of_measure to °F and the system should automatically conversation it to celcius if you have metric_system set to metric in your configuration.yaml.

2 Likes

This worked, but only for two of them… :hushed:
customize.yaml code: https://pastebin.com/WJKenBCX
configuration.yaml code: https://pastebin.com/aMMS1JuJ

In the states i can se that the sensors that work have a positive temp value, the rest have a negative value.

In my eyes the config for each sensor is identical :thinking:

good point, so the convertion might work now, but it may show wrong value also

Well, more relevant info:
https://github.com/shortbloke/home_assistant_config/blob/master/docs/devices.md

Internal Temperature and Humidity monitors WH5
Temperature readings from WH5 are 40 DegC higher than they should be. This can be corrected by use of a template i.e. `value_template: '{{ (states.sensor.temp_humid_1_temperature.attributes[“Temperature”]

Okey, all sensors identified, removed the °F/°C convertion.
looks like the link I posted above is kind of right,

looks like 2 of them just report 40°C to much
the other four show negative value when it is actualy positive, also, show 40°C to high (or low…)
![sensors|690x498](upload://mg

Anyone have a smart code for this? :thinking:

Home assistant will translate temperatures for you. So you need to specify what the units are and it will convert it for you.

so in your configuration, change the unit_of_measurement for sensor.rfxtrx_ukjent_6_temperature to ºF in your customization section.

Then in your user interface it will convert it from ºF to ºC.

So to clarify, home assistant has a ‘global temperature unit’. Yours is C. So if you specify anything with a unit of ºF in your configuration, it will properly be converted to ºC in your interface.

All in all, you don’t need your template sensor:

customize:
  sensor.rfxtrx_ukjent_6_temperature:
    unit_of_measure: F
3 Likes

Yeah, but it looks like the whole ºF to ºC. thing was a a wild trail
IF you read my two last posts. But thanks

I somehow didn’t see those posts? My browser may have not been refreshed. Anyways, is everything working or not?

HI again.

I have come farther, but it does not work completely as desired yet

This was the link i posted about my sensors: https://github.com/shortbloke/home_assistant_config/blob/master/docs/devices.md
And this is a screenshot of the post below that:

why are those temperatures negated from your sensor?

EDIT: to clarify, is there a setting in your sensor? -65.5 in any sense doesn’t make logical sense. Are they setup properly?

Well, there is not any settings on the sensors I can do, and in Home-Assistant I don’t have any settings on them.

I can se the link don’t go to the right place on the site, but this is the relevant part.

Other 433Mhz devices:
Internal Temperature and Humidity monitors WH5
Temperature readings from WH5 are 40 DegC higher than they should be. This can be corrected by use of a template i.e. `value_template: '{{ (states.sensor.temp_humid_1_temperature.attributes[“Temperature”]

This is a WH5 sensor.