Hi all, quick python_script to display the number of days until some future date, which I update using an automation at midnight daily. Enjoy!
"""
Script to create a sensor displaying the number of days until some event.
Automate to update every day.
"""
EVENT = 'renew_letsencrypt'
YEAR = 2018
MONTH = 2
DAY = 8
day_of_interest = datetime.datetime(YEAR, MONTH, DAY)
now = datetime.datetime.now()
diff = day_of_interest - now
hass.states.set('sensor.' + EVENT, diff.days,{
'unit_of_measurement': 'days',
'friendly_name': 'Days until renew LetsEncrypt',
'icon': 'mdi:calendar'
})
That looks cool however since I’m a complete noob… can you please show how you:
a) set the date that it is counting down to,
b) update it via your automation (I’m guessing that will become clearer once I understand ‘a’)
I guess I need to further understand the python_script component a bit more.
Looks very exciting. But I’m having some trouble getting it to work
Copied the configurator.py and settings.conf to my config folder. Made configurator.py executable, adding the component in my yaml file. I got the menu item now but nothing shows when I click it.
Guess it has to be some parameters that needs to be changed. But it doesn’t seem obvious to me what needs a change.
You don’t necessarily need to access it via the HASS UI while getting it to work. Initially you can also just use the IP address of the machine the configurator is running on, together with the port. So http://192.168.1.23:3218 for example. Or https of course if you have set a certificate and key. And of course it also has to be started (sudo ./configurator.py or have a look at the daemonizing section of the documentation).
Try this command to fetch the configurator.py again: curl -O https://raw.githubusercontent.com/danielperna84/hass-configurator/master/configurator.py
Then set the permissions again. The error you have described usually is a result of the content of the URL not being loaded properly.