Hi,
I am new and have done a little work on hassio. Implementation so far: Stage 1: Working Like a Charm:
I use NodeMCU with Relay board connected with Water Pump and created a switch to turn Pump ON and OFF with below code.
Note: Switch will change its state based on state_topic replyed by NodeMCU Stage 2: Working so far:
I created a input_number and do automation that if switch turned on then turn it off after X minutes. I tested and it is working with below code. configuration.yaml
input_number:
water_motor_top_timeout_box:
name: Water Motor Top Timeout (minutes)
icon: mdi:alarm
initial: 30
min: 5
max: 60
step: 1
mode: box
automations.yaml
- alias: Motor Top On Timeout Auto
trigger:
platform: state
entity_id: switch.water_motor_top
from: 'off'
to: 'on'
# for:
# seconds: "{{ input_number.water_motor_top_timeout_box }}" # not working
# seconds: '10' # work with constant
action:
service: homeassistant.turn_on
entity_id: script.water_motor_top_timer
scripts.yaml
water_motor_top_timer:
alias: Set Water Motor Top Timer
sequence:
# Cancel old timer
- service: script.turn_off
data:
entity_id: script.turn_off_water_motor_top_timer
# Start new Timer
- service: script.turn_on
data:
entity_id: script.turn_off_water_motor_top_timer
turn_off_water_motor_top_timer:
alias: Turn off water motor top timer
sequence:
- delay: '00:{{ states.input_number.water_motor_top_timeout_box.state | int }}:00'
- service: homeassistant.turn_off
entity_id: switch.water_motor_top
Issue:
Now I was thinking what happens if this automation changes the state from ON to OFF but NodeMCU does not replay with âmotor/top 0â topic. Home assistant will remain the Switch state ON because of no replay from NodeMCU in the response of automation. The motor pump will remain ON forever until the user goes to pump and manually turn it off or use hassio switch to turn it OFF manually.
Solution:
I want to automate if switch state remains unchanged even after timeout automation try again 3 times to turn pump OFF, if still the state is unchanged then Play some warning sound and display RED box with a warning in hassio gui. So User will see what happened.
How can I implement above solution, or experts suggest a better approach to this issue.
Thank you all.
Add a delay in there if you like. This is probably the best way only because there is no âloopâ ability in scripts currently. You can make a loop by daisy chaining 2 scripts and checking a counter, but itâs not worth it if you only want 3.
Also:
value_templates donât work here because itâs not supported. I believe there is a request to make that work.
thank you so much for the answer. Its almost completed. I just bring up Google TTS to notify me about the situation.
Now only I want to show a RED Warning Box Popup to user on Hassio Webpage. How can I do this. Also can I send google tts audio to server page (means hassio.local:8123) webpage. So i can listen audio notification on my laptop chrome if I opend local server page or on a android smartphone browser.
you can use this as a template for something similar to what you want. it doesnât change the color but it will display a pop up box on every page of HA until you dismiss it.