Push sensor vales to luftdaten

I love this project. I’ve adapted the code and currently I’m only pushing data to openSenseMap.org. Since I’m also pushing data from other sensors, that sometimes become unavailable, I’ve had to implement some “error-detection”. My code looks like:

post_opensensebox:
  url: !secret opensensebox_api_url
  method: POST
  headers:
    content-type: "application/json; charset=utf-8"
  payload: >-
    {
      {% if states('sensor.sensorbox_sds0x1_pm2_5') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_pm25') }}": {{ states('sensor.sensorbox_sds0x1_pm2_5') }},
      {% endif %}
      {% if states('sensor.sensorbox_sds0x1_pm10') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_pm10') }}": {{ states('sensor.sensorbox_sds0x1_pm10') }},
      {% endif %}
      {% if states('sensor.weerstation_temperatuur') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_temp') }}": {{ states('sensor.weerstation_temperatuur') }},
      {% endif %}
      {% if states('sensor.weerstation_luchtdruk_absoluut') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_press') }}": {{ ((states('sensor.weerstation_luchtdruk_absoluut') | float) * 100) | round }},
      {% endif %}
      {% if states('sensor.weerstation_luchtvochtigheid') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_hum') }}": {{ states('sensor.weerstation_luchtvochtigheid') }},
      {% endif %}
      {% if states('sensor.lichtsensor_oost_illuminance_lux') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_light_east') }}": {{ states('sensor.lichtsensor_oost_illuminance_lux') }},
      {% endif %}
      {% if states('sensor.lichtsensor_zuid_illuminance_lux') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_light_south') }}": {{ states('sensor.lichtsensor_zuid_illuminance_lux') }},
      {% endif %}
      {% if states('sensor.lichtsensor_west_illuminance_lux') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_light_west') }}": {{ states('sensor.lichtsensor_west_illuminance_lux') }},
      {% endif %}
      {% if states('sensor.weerstation_dauwpunt') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_dewpoint') }}": {{ states('sensor.weerstation_dauwpunt') }},
      {% endif %}
      {% if states('sensor.weerstation_uv') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_uvindex') }}": {{ states('sensor.weerstation_uv') }},
      {% endif %}
      {% if states('sensor.weerstation_windsnelheid') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_windsnelheid') }}": {{ states('sensor.weerstation_windsnelheid') }},
      {% endif %}
      {% if states('sensor.weerstation_windsnelheid_bft') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_windsnelheid_bft') }}": {{ states('sensor.weerstation_windsnelheid_bft') }},
      {% endif %}
      {% if states('sensor.weerstation_windrichting') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_windrichting') }}": {{ states('sensor.weerstation_windrichting') }},
      {% endif %}
      {% if states('sensor.weerstation_neerslag_mm') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_neerslag') }}": {{ states('sensor.weerstation_neerslag_mm') }},
      {% endif %}
      {% if states('sensor.weerstation_neerslag_mm_uur') not in ['unknown', 'unavailable', 'none', 'null'] %}
        "{{ states('input_text.opensensebox_sensorid_neerslag_mm') }}": {{ states('sensor.weerstation_neerslag_mm_uur') }}
      {% endif %}
    }

Since updating to 2004.1 OpenSenseMap has stopped receiving updates and I am seeing the following in the logs:

Logger: homeassistant.components.rest_command
Source: components/rest_command/__init__.py:155
Integration: RESTful Command (documentation, issues)
First occurred: 13:21:49 (1 occurrences)
Last logged: 13:21:49

Error. Url: https://api.opensensemap.org/boxes/61ae21afe0f10a001bc99668/data. Status code 422. Payload: b'{"61ae21afe0f10a001bc9966b": "10.64", "61ae21afe0f10a001bc99669": "101444.34", "61ae21afe0f10a001bc9966a": "64.03", "61ae21afe0f10a001bc9966c": "unknown", "61ae21afe0f10a001bc9966d": "18.00"}'

Anyone have any idea what the cause is and how to fix?

Turns out it was the ‘unknown’ value for the PM2.5 - which was caused because Home Assistant has somehow renamed the entity with a _2 suffix :man_shrugging:

I see that @Hmmbob blog is not available anymore. Does any of you know, where I can find some step-by-step guidance, how to make esphome sensor updating the values to sensor.community?

Yeah, Tweakers took down the blogging platform. However, my code is available on GitHub, maybe that helps? It has some comments embedded in the code to help you get started.

1 Like

Thanks a lot, will try to go through it.