using a etc_offset template sensor:
- unique_id: utc_offset
name: Utc offset
state: >
{{now().utcoffset().total_seconds()/3600}}
icon: >
{% set offset = now().utcoffset().total_seconds()/3600 %}
mdi:numeric-{{offset|int|abs}}
in my python scripts:
utc_offset = hass.states.get('sensor.utc_offset').state
timeDifference = float(utc_offset) # <-- line 22
every now and then I see this error in the homeassistant.log
Logger: homeassistant.components.python_script.summary_active.py
Source: components/python_script/__init__.py:222
Integration: Python Scripts (documentation, issues)
First occurred: 10:19:10 (1 occurrences)
Last logged: 10:19:10
Error executing script: could not convert string to float: 'unavailable'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 222, in execute
exec(compiled.code, restricted_globals)
File "summary_active.py", line 22, in <module>
ValueError: could not convert string to float: 'unavailable'
it is used in the python script like:
for entity_id in hass.states.get(group).attributes['entity_id']:
state = hass.states.get(entity_id)
if (state.state == filter or debug):
dt = state.last_changed + datetime.timedelta(hours= timeDifference)
time = '%02d:%02d' % (dt.hour, dt.minute)
I guess it has to do with the new template default values, but am not sure how to fix this in the python script.
maybe like:
for entity_id in hass.states.get(group).attributes['entity_id']:
state = hass.states.get(entity_id)
if (state.state == filter and timeDifference is not None or debug):
dt = state.last_changed + datetime.timedelta(hours= timeDifference)
time = '%02d:%02d' % (dt.hour, dt.minute)
cant imagine it is the icon template throwing the issue?
Please have a look with me?
thanks.