Converting Sensor Measurement Units

Thanks for the quick response! float(0) worked and I see now that AirThings Radon is unavailable…not sure why it stopped sending.

Thank you for this @qwertyphile and @petro. The code, with the float(0) modification, worked perfectly for me.

why float(0)

Because the word “unavailable” isn’t a number. So when float tries to converts the value, it errors. Providing zero gives it a default of zero when this happens.

1 Like

I’m having trouble getting this to work. My YAML is not generating a configuration error, but I suspect I’m not not using correct names.

I have two Airthings “Wave Radon” sensors. So I’m guessing the sensor.airthings_radon wont work as shown above. If I click on the dashboard cards I can click a radon measurement and then click the settings gear. This tells me that the EntityID is sensor.wave_radon_2_radon for one and sensor.wave_radon_1_radon for the other.

Based on this I added the following to my /config/configuration.yaml:

    template:
      - sensor:
          - name: "Wave Radon 1 Radon"
            unit_of_measurement: "pCi/L"
            state: "{{ (states('sensor.wave_radon_1_radon') | float / 37) | round(2) }}"

I understand YAML well, but what I don’t understand is how this structure is interpreted.

However, on restarting the service I the units on the cards did not update. They are still in Bq/M^3. Am I doing something wrong?

I’m also curious how this configuration.yaml is read and applied. What are the entries in the “template” list doing? I assume it loops over each one, checks its type based on a key, but then that contains another list? Should I expecting this to be overriding the units in the existing Airthings cards on my dashboard, or do I have to use this to create a new card?

EDIT:

I do see it in a new card called “Sensor”. Is there anyway that I can modify how it is displayed in existing cards?