original_docstring:  Handles firing of an event.
  
      This handles the following paths:
      /api/events/<event_type>
  
      Events from /api are threated as remote events.
      
docstring: Handles firing of an event.
  This handles the following paths:
  api/events/
  
  Events from /api are threated as remote events.
docstring_tokens: Handles firing of an event . This handles the following paths : api / events / Events from / api are threated as remote events .
code: def _handle_api_post_events_event(handler, path_match, event_data):
      """ Handles firing of an event.
  
      This handles the following paths:
      /api/events/<event_type>
  
      Events from /api are threated as remote events.
      """
      event_type = path_match.group('event_type')
  
      if event_data is not None and not isinstance(event_data, dict):
          handler.write_json_message(
              "event_data should be an object", HTTP_UNPROCESSABLE_ENTITY)
  
      event_origin = ha.EventOrigin.remote
  
      # Special case handling for event STATE_CHANGED
      # We will try to convert state dicts back to State objects
      if event_type == ha.EVENT_STATE_CHANGED and event_data:
          for key in ('old_state', 'new_state'):
              state = ha.State.from_dict(event_data.get(key))
  
              if state:
                  event_data[key] = state
  
      handler.server.hass.bus.fire(event_type, event_data, event_origin)
  
      handler.write_json_message("Event {} fired.".format(event_type))
code_tokens: def _handle_api_post_events_event ( handler , path_match , event_data ) : event_type = path_match . group ( 'event_type' ) if event_data is not None and not isinstance ( event_data , dict ) : handler . write_json_message ( "event_data should be an object" , HTTP_UNPROCESSABLE_ENTITY ) event_origin = ha . EventOrigin . remote if event_type == ha . EVENT_STATE_CHANGED and event_data : for key in ( 'old_state' , 'new_state' ) : state = ha . State . from_dict ( event_data . get ( key ) ) if state : event_data [ key ] = state handler . server . hass . bus . fire ( event_type , event_data , event_origin ) handler . write_json_message ( "Event {} fired." . format ( event_type ) )
short_docstring: Handles firing of an event.
short_docstring_tokens: Handles firing of an event .
comment: """ Handles firing of an event.
  
      This handles the following paths:
      /api/events/<event_type>
  
      Events from /api are threated as remote events.
      """$SEP$# Special case handling for event STATE_CHANGED$SEP$# We will try to convert state dicts back to State objects