Hello, thank you “mviezzer” for this awsome feature.
I would love to use it for my harmony hub current activity sensor but unfortunatly it’s not working. I just have a white blank badge with the text “ACT” int the red little bubble.
Maybe if you have the time to check my code you will find the error i have made:
sensor:
- platform: template
sensors:
harmony_hub_sensor:
value_template: '{{ states.remote.harmony_hub.attributes.current_activity }}'
friendly_name: 'harmony hub sensor'
input_select:
harmony_hub:
name: Harmony Hub
options:
- Power Off
- TV
- PC TV
- SMART TV
- MOVIES TV
- SWITCH TV
- PS4 TV
- ONE TV
- WiiU TV
- PS3 TV
- 360 TV
- PC
- MOVIES
- SWITCH
- PS4
- ONE
- WiiU
- PS3
- 360
- Chromecast audio
initial: Power Off
icon: mdi:monitor
group:
activity:
name: Main activity
entities:
- input_select.harmony_hub
- sensor.harmony_hub_sensor
automations:
- alias: 'Activity change'
hide_entity: True
initial_state: 'on'
trigger:
- platform: state
entity_id: input_select.harmony_hub
action:
- service: python_script.activity
data_template:
event: "{{ trigger.event }}"
- service: python_script.summary
data_template:
event: "{{ trigger.event }}"
- alias: 'Call Script Event'
hide_entity: True
initial_state: 'on'
trigger:
- platform: event
event_type: call_service
event_data:
domain: script
action:
- delay: 00:00:02
- service: python_script.last_cmd
data_template:
event: "{{ trigger.event }}"
activity.py:
# Get params
event = data.get('event')
# Get the state object from the name
state_value = hass.states.get('input_select.harmony_hub').state
# Get info
dt = datetime.datetime.now() #state.attributes.get('last_triggered')
time = "%02d:%02d" % (dt.hour, dt.minute)
# Sensor update
hass.states.set('sensor.harmony_hub_sensor', state_value, {
'friendly_name': ' ',
'entity_picture': '/local/activities/{}.png'.format(state_value.lower()),
'unit_of_measurement': 'Act'
})
I have added the “python_script:” line in the config.
I have renamed all the .png files to match the name of the inputs and placed them in the “activities” folder(for exemple the activity PC TV=pc tv.png).
Do i have to edit the “python_script.summary” and “python_script.last_cmd” to get it working?
I’m receiving errors now in the log file.:
2018-02-03 22:51:50 ERROR (SyncWorker_0) [homeassistant.components.python_script.last_cmd.py] Error executing script: 'NoneType' object is not callable
Traceback (most recent call last):
File "/usr/src/app/homeassistant/components/python_script.py", line 166, in execute
exec(compiled.code, restricted_globals, local)
File "last_cmd.py", line 22, in <module>
TypeError: 'NoneType' object is not callable
2018-02-03 22:51:50 ERROR (SyncWorker_8) [homeassistant.components.python_script.last_cmd.py] Error executing script: 'NoneType' object is not callable
Traceback (most recent call last):
File "/usr/src/app/homeassistant/components/python_script.py", line 166, in execute
exec(compiled.code, restricted_globals, local)
File "last_cmd.py", line 22, in <module>
TypeError: 'NoneType' object is not callable
2018-02-03 22:51:50 ERROR (SyncWorker_12) [homeassistant.components.python_script.last_cmd.py] Error executing script: 'NoneType' object is not callable
Traceback (most recent call last):
File "/usr/src/app/homeassistant/components/python_script.py", line 166, in execute
exec(compiled.code, restricted_globals, local)
File "last_cmd.py", line 22, in <module>
TypeError: 'NoneType' object is not callable
2018-02-03 22:51:50 ERROR (SyncWorker_4) [homeassistant.components.python_script.last_cmd.py] Error executing script: 'NoneType' object is not callable
Traceback (most recent call last):
File "/usr/src/app/homeassistant/components/python_script.py", line 166, in execute
exec(compiled.code, restricted_globals, local)
File "last_cmd.py", line 22, in <module>
TypeError: 'NoneType' object is not callable
2018-02-03 22:52:03 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting
Thank you.