2018-05-10 09:29:43 ERROR (Thread-18) [homeassistant.components.python_script.wekkertijd.py] Error executing script: ‘dict’ object has no attribute ‘lower’
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/python_script.py”, line 166, in execute
exec(compiled.code, restricted_globals, local)
File “wekkertijd.py”, line 45, in
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 905, in call
self._hass.loop
File “/usr/lib/python3.5/concurrent/futures/_base.py”, line 405, in result
return self.__get_result()
File “/usr/lib/python3.5/concurrent/futures/_base.py”, line 357, in __get_result
raise self._exception
File “/usr/lib/python3.5/asyncio/tasks.py”, line 239, in _step
result = coro.send(None)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/core.py”, line 932, in async_call
ATTR_SERVICE: service.lower(), AttributeError: ‘dict’ object has no attribute ‘lower’
At this point, the Squeezebox API is not yet called, so the error comes from HomeAssistant itself.
I don’t understand what is meant with ‘dict’ and ‘lower’, those terms are not in my code.
I run HomeAssistant on Raspbian by the way, not Hass.io
it doesn’t look like that error is coming from squeezebox, it looks like its coming from wekkertijd.py. Is that a custom component of yours? I don’t see it in the HA repository.
The wekkertijd.py is the python script that I wrote containing the above code (of course later it will be expanded to calculate the desired alarm clock time) and run via:
I wanted to use python to call script.dimmer with variables light_id and swipe_action. I cannot seem to fire off the script with this python code. Can you please point me in the right direction? Thank you.
It still doesn’t work. The script didn’t get called.
Below is the python script:
event = data.get('event')
label = data.get('label')
index = data.get('index')
node_id = int(data.get('node_id'))
# we only care about index == 10, the end of the swipe 'parameter'
# and for safety we also only look at valueChanged
if (index == '10') and event == 'valueChanged':
value = int(data.get('value', '0'))
# unpack byte 2 (button id)
scene_id = value >> 24 & 0xff
# unpack byte 3 (direction)
scene_value_id = value >> 16 & 0xff
# offset by 10 to avoid colissions
scene_value_id = scene_value_id + 10
scene_value_label = 'Swipe Down'
if scene_value_id == 11:
scene_value_label = 'Swipe Up'
if '7' in node_id:
node = 'bedroom'
if '4' in node_id:
node = 'livingroom'
if 'livingroom' in node:
if '1' in scene_id:
light_id = 'light.living_room_lights'
if '2' in scene_id:
light_id = 'light.dining_lights'
if '3' in scene_id:
light_id = 'light.corner_lights'
if '4' in scene_id:
light_id = 'light.stairs_lights'
elif 'bedroom' in node:
if '1' in scene_id:
light_id = 'light.bedroom_lights'
swipe_action = scene_value_label
hass.services.call('script', 'turn_on', {
'entity_id': 'script.dimmer',
'light_id': light_id,
'swipe_action': swipe_action,
}, False)
I have searched in the forum but couldn’t find any good examples of calling script service from python. I still don’t know where it goes wrong. Thank you for your help.