Hi
I’ve created a custom python script to countdown days until specific DAY OF THE WEEK
All required info/help can be found inside:
""" This script creates a sensor that a counts down to the next occurrance """
""" of a day , like a recurrence meetings """
""" Requires python_script: to be enabled in you configuration """
""" Usage: """
""" """
""" automation: """
""" alias: Refresh Plastic Bin sensor """
""" trigger: """
""" platform: time """
""" at: '00:00:01' """
""" action: """
""" service: python_script.day_countdown """
""" data: """
""" name: Plastic """
""" type: Bin """
""" day: 0 # 0-6(monday0-sunday6) """
""" This will create a sensor with entity_id sensor.plastic_bin and a """
""" friendly name of 'Plastic Bin' . The sensors value will be the """
""" number of days until the provided day """
today = int(datetime.datetime.now().weekday())
name = data.get('name')
type = data.get('type')
sensorName = "sensor.{}_{}".format(type, name.replace(" ", "_"))
day = int(data.get('day')) # 0(Monday),6(Sunday)
if day == today:
result = 0
elif day > today:
result = day - today
else:
result = 7 - abs(day - today)
hass.states.set(sensorName, result,
{
"icon": "mdi:calendar-star",
"unit_of_measurement": "days",
"friendly_name": "{} {}".format(name, type)
}
)