We are live!
the project: https://meetjestad.net/
info: https://meetjestad.net/node/1084
data: https://meetjestad.net/data/sensors_recent.php?sensor=1084&limit=12
json: https://meetjestad.net/data/?type=sensors&ids=1084&format=json&limit=1
Utrecht: https://meetjestad.net/index3.php?loc=Ut
RIVM: https://samenmeten.rivm.nl/dataportaal/sensor_dashboard.php?kit_id=MJS_1084#tabs-2
Of course I wanted to add the data to my own Home Assistant installation. For this I had to add some custom sensors to:
\\NAS\docker\homeassistant\config\configuration.yaml
rest:
- resource: "https://meetjestad.net/data/?type=sensors&ids=1084&format=json&limit=1"
scan_interval: 00:15:00
sensor:
- name: "mjs_1084_humidity"
unique_id: mjs_1084_humidity
value_template: '{{ (value_json[0].humidity | float) | round(1) }}'
device_class: humidity
state_class: measurement
unit_of_measurement: "%"
availability: '{{ ((value_json[0].humidity | float) >= 0) and ((value_json[0].humidity | float) <= 100) }}'
- name: "mjs_1084_temperature"
unique_id: mjs_1084_temperature
value_template: '{{ (value_json[0].temperature | float) | round(1) }}'
device_class: temperature
state_class: measurement
unit_of_measurement: "°C"
availability: '{{ ((value_json[0].temperature | float) > -25) and ((value_json[0].temperature | float) < 100) }}'
- name: "mjs_1084_pm25"
unique_id: mjs_1084_pm25
value_template: '{{ (value_json[0]["pm2.5"] | float) | round(0) }}'
device_class: pm25
state_class: measurement
unit_of_measurement: "µg/m³"
availability: '{{ ((value_json[0]["pm2.5"] | float) >= 0) and ((value_json[0]["pm2.5"] | float) < 50000) }}'
- name: "mjs_1084_pm10"
unique_id: mjs_1084_pm10
value_template: '{{ (value_json[0].pm10 | float) | round(0) }}'
device_class: pm10
state_class: measurement
unit_of_measurement: "µg/m³"
availability: '{{ ((value_json[0].pm10 | float) >= 0) and ((value_json[0].pm10 | float) < 50000) }}'
- name: "mjs_1084_battery_voltage"
unique_id: mjs_1084_battery_voltage
value_template: '{{ (value_json[0].supply | float) | round(2) }}'
device_class: voltage
state_class: measurement
unit_of_measurement: V
- name: "mjs_1084_timestamp"
unique_id: mjs_1084_timestamp
device_class: timestamp
value_template: "{{ strptime( value_json[0].timestamp ~ '+00:00' , '%Y-%m-%d %H:%M:%S%z') }}"
* Please note some changes I made, compared to the instructions I found here. The following does not work:
value_template: '{{ (value_json[0].pm2.5 | float) }}'
I had to use:
value_template: '{{ (value_json[0]["pm2.5"] | float) | round(0) }}'
* I added the timestamp as a sensor as well, so I could see when the last data packet was transmitted. For the timestamp, the following did not quite work. It just gave me the UTC time:
value_template: "{{ value_json[0].timestamp | as_datetime | as_local }}"
So, I had to add some string manipulation to get the data in the correct timezone:
value_template: "{{ strptime( value_json[0].timestamp ~ '+00:00' , '%Y-%m-%d %H:%M:%S%z') }}"
* And to filter out invalid data, like temperature at -26 or pm at over 50k, I had to add some availability filters, like so:
availability: '{{ ((value_json[0].pm10 | float) >= 0) and ((value_json[0].pm10 | float) < 50000) }}'
That’s all folks…
Have a nice day!