""" trigger file.wall_buttons.hallway_wall_button got event trigger, running action (kwargs = { 'trigger_type': 'event', 'event_type': 'button_pressed', 'context': Context(user_id=None, parent_id=None, id='67d442d5b0b4c1f3308417722801f709'), 'entity_id': 'switch.hall_switch', 'state': 'on' }) kalle = kwargs.context.get("entity_id", None) ^ AttributeError: 'dict' object has no attribute 'context' """ # Mode Panel: # 1: All ON # 2: Windows # 3: Morning-mode # 4: All OFF """ ERROR: 2021-05-13 20:52:14 ERROR (MainThread) [custom_components.pyscript.function] run_coro: got exception Traceback (most recent call last): File "/config/custom_components/pyscript/eval.py", line 710, in call raise TypeError(f"{self.name}() called with unexpected keyword arguments: {unexpected}") TypeError: hallway_wall_button() called with unexpected keyword arguments: state got button_pressed: kwargs={ 'trigger_type': 'event', 'event_type': 'button_pressed', 'context': Context(user_id=None, parent_id=None, id='01ce32cfcc4bed50ce9301ae967fa951'), 'entity_id': 'switch.mode_panel_4', 'state': 'off'} """ @event_trigger( "button_pressed" ) def hallway_wall_button(entity_id=None, state=None): log.info(f"**************** got EVENT_CALL_SERVICE with Id:{entity_id} State:{state}") if( entity_id == 'switch.hall_switch' ): if( switch.group_button_all == 'on'): pyscript.state_goto_all_off() else: pyscript.state_goto_all_on() if( entity_id == 'switch.mode_panel_1' ): # All ON pyscript.state_goto_all_on() if( entity_id == 'switch.mode_panel_2' ): # Window pyscript.state_goto_window() if( entity_id == 'switch.mode_panel_3' ): # Morning pyscript.state_goto_morning() if( entity_id == 'switch.mode_panel_4' ): # All OFF pyscript.state_goto_all_off()