I have a temp sensor that sometimes goes offline.
as I have to start a timer depending on the temperature I’ve used a Case.
The issue is that when the sensor is offline the default actions is not executed as the script is terminated with error:
Executed: August 2, 2022 at 4:41:31 PM
Result:
result: false
## entity_id/0
Executed: August 2, 2022 at 4:41:31 PM
Result:
result: false message: value 'unavailable' is non-numeric and treated as False
here is the script:
alias: Piscina Pump Schedule
description: ''
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.piscina_prerun
condition: []
action:
- service: notify.piscinalog
data:
message: Piscina Pump Schedule
title: Piscina Pump Schedule
- service: notify.whatsapp
data:
message: The temperature is {{ states('sensor.sonoff_10001c5cd2_temperature') }}
- condition: numeric_state
entity_id: sensor.sonoff_10001c5cd2_temperature
above: '12'
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.sonoff_10001c5cd2_temperature
above: '12'
below: '20'
sequence:
- service: timer.start
data:
duration: '02:45:00'
target:
entity_id: timer.piscina
- service: notify.piscinalog
data:
message: >-
The temperature is {{
states('sensor.sonoff_10001c5cd2_temperature') }} - 02:45:00.
title: Piscina Pump Schedule - On
- conditions:
- condition: numeric_state
entity_id: sensor.sonoff_10001c5cd2_temperature
above: '20'
below: '25'
sequence:
- service: timer.start
data:
duration: '06:45:00'
target:
entity_id: timer.piscina
- service: notify.piscinalog
data:
message: >-
The temperature is {{
states('sensor.sonoff_10001c5cd2_temperature') }} - 06:45:00.
title: Piscina Pump Schedule - On
- conditions:
- condition: numeric_state
entity_id: sensor.sonoff_10001c5cd2_temperature
above: '25'
below: '28'
sequence:
- service: timer.start
data:
duration: '08:45:00'
target:
entity_id: timer.piscina
- service: notify.piscinalog
data:
message: >-
The temperature is {{
states('sensor.sonoff_10001c5cd2_temperature') }} - 08:45:00.
title: Piscina Pump Schedule - On
- conditions:
- condition: numeric_state
entity_id: sensor.sonoff_10001c5cd2_temperature
above: '28'
below: '45'
sequence:
- service: timer.start
data:
duration: '09:45:00'
target:
entity_id: timer.piscina
- service: notify.piscinalog
data:
message: >-
The temperature is {{
states('sensor.sonoff_10001c5cd2_temperature') }} - 10:45:00.
title: Piscina Pump Schedule - On
default:
- service: notify.piscinalog
data:
message: >-
The temperature is {{ states('sensor.sonoff_10001c5cd2_temperature')
}} - Error.
title: Piscina Pump Schedule - On
- service: timer.start
data:
duration: '03:45:00'
target:
entity_id: timer.piscina
mode: single