Ok got it setup but have run into some errors. I can get it to trigger, but cant figure out how to proceed.
This python script =
entity_id = data.get(‘binary_sensor.samjin_button_0100bd6b_1_1280’)
if not entity_id:
logger.error(‘No entity_id provided’)
state = data.get(‘off’)
if not state:
logger.error(‘No state provided’)
hass.states.set(entity_id, state)
Gives this error =
2018-09-05 22:43:44 INFO (MainThread) [homeassistant.helpers.script] Script Exit Button - Test: Executing step call service
2018-09-05 22:43:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=exit_button_reset, service_data=>
2018-09-05 22:43:44 INFO (SyncWorker_13) [homeassistant.components.python_script] Executing exit_button_reset.py: {}
2018-09-05 22:43:44 ERROR (SyncWorker_13) [homeassistant.components.python_script.exit_button_reset.py] No entity_id provided
2018-09-05 22:43:44 ERROR (SyncWorker_13) [homeassistant.components.python_script.exit_button_reset.py] No state provided
2018-09-05 22:43:44 ERROR (SyncWorker_13) [homeassistant.components.python_script.exit_button_reset.py] Error executing script: ‘NoneType’ object has no attribute ‘lower’
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/python_script.py”, line 166, in execute
exec(compiled.code, restricted_globals, local)
File “exit_button_reset.py”, line 7, in
File “/usr/local/lib/python3.6/site-packages/homeassistant/core.py”, line 815, in set
context,
File “/usr/local/lib/python3.6/concurrent/futures/_base.py”, line 432, in result
return self.__get_result()
File “/usr/local/lib/python3.6/concurrent/futures/_base.py”, line 384, in __get_result
raise self.exception
File "/usr/local/lib/python3.6/site-packages/homeassistant/util/async.py", line 176, in run_callback
future.set_result(callback(*args))
File “/usr/local/lib/python3.6/site-packages/homeassistant/core.py”, line 832, in async_set
entity_id = entity_id.lower()
AttributeError: ‘NoneType’ object has no attribute ‘lower’
If I comment out the logger part in the script like this =
entity_id = data.get(‘binary_sensor.samjin_button_0100bd6b_1_1280’)
if not entity_id:
#…logger.error(‘No entity_id provided’)
state = data.get(‘off’)
if not state:
#…logger.error(‘No state provided’)
hass.states.set(entity_id, state)
I get this error =
2018-09-05 22:48:28 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]>
2018-09-05 22:48:28 INFO (MainThread) [homeassistant.helpers.script] Script Exit Button - Test: Executing step call service
2018-09-05 22:48:28 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=python_script, service=exit_button_reset, service_data=>
2018-09-05 22:48:28 ERROR (SyncWorker_5) [homeassistant.components.python_script] Error loading script exit_button_reset.py: Line 4: IndentationError: expected an indented block in on statement: state = data.get(‘off’)
2018-09-05 22:48:28 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]>
I have tried a few variables but cant seem to figure it out. Thanks for the support, I feel we are almost there!
I was thinking, could I call hass.states.set directly from the automation? I used this as the service data =
{
“entity_id”: “binary_sensor.samjin_button_0100bd6b_1_1280”,
“state”: “off”
}
And get this as the error at the top =
Message malformed: Service hass.scripts.set does not match format <domain>.<name> for dictionary value @ data[‘action’][1][‘service’]
Again, thanks for the help!