well something is happening, this automation got triggered:
Fri Jul 13 2018 15:53:11 GMT+0200 (CEST)
LAST AUTOMATION: <Event call_service[L]: domain=automation, service=trigger, service_data=entity_id=automation.call_summary, service_call_id=1971637392-1888>
but immediately above that is this:
Fri Jul 13 2018 15:53:11 GMT+0200 (CEST)
Error executing script: '__import__'
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/components/python_script.py", line 166, in execute
exec(compiled.code, restricted_globals, local)
File "last_automation.py", line 17, in <module>
KeyError: '__import__'
line 17 being: time_string = datetime.datetime.now().strftime('%I:%M')
must be the old time issue we had before…so,
ive changed that back into this:
state = hass.states.get(entity_id)
# Make a time string in 24 hour format
#time_string = datetime.datetime.now().strftime('%I:%M')
dt = datetime.datetime.now() #state.attributes.get('last_triggered') #
time = "%02d:%02d" % (dt.hour, dt.minute)
# try to get the automation friendly name
try:
msg = state.name
except:
msg = None
if msg:
if not msg.startswith('Set '):
# Sensor update
hass.states.set('sensor.last_automation', '{}'.format( msg), {
# 'custom_ui_state_card': 'state-card-value_only',
# 'text': sensor_message,
'unit_of_measurement': 'Aut',
'friendly_name': time,
'entity_picture': '/local/buttons/play-mode-repeat.png' })
and, lo and behold:
![12](//community-assets.home-assistant.io/original/3X/8/6/86e5b352e73057fa443d03cb909533383d3a34dc.jpg)
progress! now lets see why this is not displayed too when being triggered manually…![:wink: :wink:](https://community.home-assistant.io/images/emoji/twitter/wink.png?v=9)
thanks @petro, much appreciated, as ever!
next up investigate why this works, and the other script failed to populate the sensor.