Hi all,
I’ve configured some REST sensors for some pool monitoring probes:
- platform: rest
resource: https://api.thingspeak.com/channels/123/fields/1.json?api_key= XYZ&results=1
name: Pool Water pH
value_template: '{{ float(value_json["feeds"][0]["field1"]) }}'
unique_id: sensor.pool_ph
device_class: ph
- platform: rest
resource: https://api.thingspeak.com/channels/123/fields/2.json?api_key= XYZ&results=1
name: Pool ORP (mV)
value_template: '{{ float(value_json["feeds"][0]["field2"]) }}'
unit_of_measurement: 'mV'
unique_id: sensor.pool_orp
- platform: rest
resource: https://api.thingspeak.com/channels/123/fields/3.json?api_key=XYZ&results=1
name: Pool Temperature
value_template: '{{ float(value_json["feeds"][0]["field3"]) }}'
unit_of_measurement: '°C'
unique_id: sensor.pool_temperature
device_class: temperature
However, upon attempting to configure statistics against them, only the temperature one seems to work; the others return “unavailable”:
- platform: statistics
name: "Pool pH mean over last 24 hours"
entity_id: sensor.pool_ph
state_characteristic: mean
unique_id: sensor.pool_ph_mean
max_age:
hours: 24
- platform: statistics
name: "Pool ORP mean over last 24 hours"
entity_id: sensor.pool_orp
state_characteristic: mean
unique_id: sensor.pool_orp_mean
max_age:
hours: 24
- platform: statistics
name: "Pool temperature mean over last 24 hours"
entity_id: sensor.pool_temperature
state_characteristic: mean
unique_id: sensor.pool_temperature_mean
max_age:
hours: 24
Checking via template editor:
{{ states.sensor.pool_orp_mv }}
{{ states.sensor.pool_temperature }}
{{ states.sensor.pool_water_ph }}
{{ states.sensor.pool_ph_mean_over_last_24_hours }}
{{ states.sensor.pool_temperatur_mean_over_last_24_hours }}
{{ states.sensor.pool_orp_mean_over_last_24_hours }}
<template TemplateState(<state sensor.pool_orp_mv=704.0; unit_of_measurement=mV, friendly_name=Pool ORP (mV) @ 2024-05-19T10:53:48.527488-07:00>)>
<template TemplateState(<state sensor.pool_temperature=79.48; unit_of_measurement=°F, device_class=temperature, friendly_name=Pool Temperature @ 2024-05-19T10:54:48.494785-07:00>)>
<template TemplateState(<state sensor.pool_water_ph=6.96; device_class=ph, friendly_name=Pool Water pH @ 2024-05-19T10:55:48.510120-07:00>)>
<template TemplateState(<state sensor.pool_ph_mean_over_last_24_hours=**unavailable**; state_class=measurement, icon=mdi:calculator, friendly_name=Pool pH mean over last 24 hours @ 2024-05-19T10:41:48.851330-07:00>)>
<template TemplateState(<state sensor.pool_temperatur_mean_over_last_24_hours=**27.26**; state_class=measurement, age_coverage_ratio=0.01, source_value_valid=True, unit_of_measurement=°F, device_class=temperature, icon=mdi:calculator, friendly_name=Pool temperatur mean over last 24 hours @ 2024-05-19T10:54:48.499140-07:00>)>
<template TemplateState(<state sensor.pool_orp_mean_over_last_24_hours=**unavailable**; state_class=measurement, icon=mdi:calculator, friendly_name=Pool ORP mean over last 24 hours @ 2024-05-19T10:42:58.899880-07:00>)>
Any indications on why this might be happening?
Thank you!