I have a template sensor wich returns a date like 27-2-2019. The problem is that my date sensor returns 27-02-2019. One extra zero. I want a automation that gives me a notification when the date (pickup of paper) is today. Has somone a solution for me.
I now have these sensor and automation. I’ve test it with replacing the “sensor.ophaaldag_papier” for a custom time sensor in te same format (without zero). That works. So now I will wait until the next pickup on 27-02-2019. Then I’ll know for sure or my automation will work.
- platform: scrape
resource: https://www.xxxxxx
name: Papier
select: "#CphContent_upPickUpDates > ul > li.papier"
#value_template: "{{ value.split(':')[1]|replace('div', ' ')|trim }}"
scan_interval: 21600 #6u
- platform: template
sensors:
ophaaldag_papier:
value_template: >-
{% set strtext = states.sensor.papier.state.replace('Papier en Karton',' ') %} {{ strptime(strtext, '%a, %d %b %Y %H:%M:%S%z') }}
- id: papieraandewegzetten
alias: 'Papier ophaaldag'
initial_state: 'on' #on reboot HA or reloading of automations, automation is ON
trigger:
- platform: time
at: 06:50:10
condition:
condition: and # all conditions need to be True before action is executed.
conditions:
- condition: template # When dates are the same action is executed.
value_template: >
{% if is_state('sensor.ophaaldag_papier',now().strftime("%d-%m-%Y")) %} True
{% else %} False
{% endif %}
action:
- service: notify.pushallphones
data:
message: 'Het is vandaag {{ now().strftime("%d %B") }}. Zet de Papier Klikko aan de weg!'
data:
push:
attachment:
url: https://hassiorxxxx.duckdns.org:8123/local/icons/ophaaldagklikko/papier1.png
Another question related to scraoe sensors. Is it possible to make a time window within the scrape sensor is working. I use more scrape sensors and some websites are not accessible during the night. And then I have a lot of errors in my log.
I have another challenge. I want also a trigger the day before mij garbage will be pickup. I’n struggling a few hours, and can’t figure it out. Can someone help me?
But that doesn’t work unfortunately
Below my working example for the day my garbage will be pickup.
- condition: template # When dates are the same action is executed.
value_template: >
{% if is_state('sensor.ophaaldag_papier',now().strftime("%d-%m-%Y")) %} True
{% else %} False
{% endif %}