'NoneType' object is not callable

HI,

the below error message is obvious, but what am i supposed to do about it…?

Log Details (ERROR)
Fri Dec 08 2017 16:30:40 GMT+0100 (CET)

Error executing script: 'NoneType' object is not callable
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_cmd.py", line 18, in <module>
TypeError: 'NoneType' object is not callable

referenced script is as follows:

# Get params
event = data.get('event')
# logger.error("LAST CMD: " + str(event))
# Sample: <Event call_service[L]: service_data=, service_call_id=78356624-86, service=mp_playpause, domain=script>

# Find the script name. TODO: Is it possible do with regex, dictionary, json...?
pos_start = event.find('service=')+8
pos_end = event.find(',', pos_start)

# Get the state object (script) from the name
entity_id = 'script.' + event[pos_start:pos_end]
state = hass.states.get(entity_id)
dt = datetime.datetime.now() #state.attributes.get('last_triggered')
time = "%02d:%02d" % (dt.hour, dt.minute)

# Ignore some names
msg = state.name
if (msg == 'None') or (msg.startswith('Set ')):
    msg = ''

if (msg != '') :
    # Sensor update
    hass.states.set('sensor.last_command', '{} - {}'.format(time, msg), {
        'custom_ui_state_card': 'state-card-value_only'
    })

Is it an obvious syntax error, or could it be related to the recent updating of the custom ui files?
Please have a look,

Marius

This means that the variable msg is of type none, so couldn’t be used to call startswith

msg is none probably because entity_id did not match a vaild entity.

entity_id may be wrong because the pos_start and pos_end haven’t worked as you expected, or there may be no entity actually matching what they decode.

Some extra logging will figure out which of these is true.

thanks,
to narrow it down as strict as possible, which domain should i turn up de logging for best?
I’ve tried homeassistant.components.python_script at level info, but see no additional info in the log

I have never used python_script so I can’t be sure, but if you just add some lines like

    logger.error(msg)

you should see something.