brianjking / homeassistant-config

Configuration for @brianjking Home Assistant
https://home-assistant.io
82 stars 8 forks source link

Log Level input_select w/ automation -- help #99

Closed brianjking closed 7 years ago

brianjking commented 7 years ago

@CCOSTAN -- I saw this log level automation in your repo and implemented it, however, it doesn't seem to actually change the log level. Is yours working?

home-assistant.log

17-04-24 13:40:42 INFO (MainThread) [homeassistant.components.http] Serving / to 127.0.0.1 (auth: False)
17-04-24 13:40:43 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 1825340304: Received {'service': 'select_option', 'service_data': {'option': 'fatal', 'entity_id': 'input_select.log_level'}, 'id': 10, 'domain': 'input_select', 'type': 'call_service'}
17-04-24 13:40:43 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service=select_option, service_data=option=fatal, entity_id=input_select.log_level, domain=input_select, service_call_id=1978185328-102>
17-04-24 13:40:43 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=<state input_select.log_level=warn; friendly_name=Log Level, options=['critical', 'fatal', 'error', 'warning', 'warn', 'info', 'debug', 'notset'] @ 2017-04-23T12:41:10.470321-05:00>, new_state=<state input_select.log_level=fatal; friendly_name=Log Level, options=['critical', 'fatal', 'error', 'warning', 'warn', 'info', 'debug', 'notset'] @ 2017-04-24T13:40:43.564120-05:00>, entity_id=input_select.log_level>
17-04-24 13:40:43 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 1825546192: Sending {'event': {'data': {'entity_id': 'input_select.log_level', 'new_state': <state input_select.log_level=fatal; friendly_name=Log Level, options=['critical', 'fatal', 'error', 'warning', 'warn', 'info', 'debug', 'notset'] @ 2017-04-24T13:40:43.564120-05:00>, 'old_state': <state input_select.log_level=warn; friendly_name=Log Level, options=['critical', 'fatal', 'error', 'warning', 'warn', 'info', 'debug', 'notset'] @ 2017-04-23T12:41:10.470321-05:00>}, 'time_fired': datetime.datetime(2017, 4, 24, 18, 40, 43, 564237, tzinfo=<UTC>), 'event_type': 'state_changed', 'origin': 'LOCAL'}, 'id': 2, 'type': 'event'}
17-04-24 13:40:43 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 1825340304: Sending {'event': {'data': {'entity_id': 'input_select.log_level', 'new_state': <state input_select.log_level=fatal; friendly_name=Log Level, options=['critical', 'fatal', 'error', 'warning', 'warn', 'info', 'debug', 'notset'] @ 2017-04-24T13:40:43.564120-05:00>, 'old_state': <state input_select.log_level=warn; friendly_name=Log Level, options=['critical', 'fatal', 'error', 'warning', 'warn', 'info', 'debug', 'notset'] @ 2017-04-23T12:41:10.470321-05:00>}, 'time_fired': datetime.datetime(2017, 4, 24, 18, 40, 43, 564237, tzinfo=<UTC>), 'event_type': 'state_changed', 'origin': 'LOCAL'}, 'id': 2, 'type': 'event'}
17-04-24 13:40:43 INFO (MainThread) [homeassistant.components.automation] Executing Log Level
17-04-24 13:40:43 INFO (MainThread) [homeassistant.core] Bus:Handling <Event logbook_entry[L]: name=Log Level, entity_id=automation.log_level, domain=automation, message=has been triggered>
17-04-24 13:40:43 INFO (MainThread) [homeassistant.helpers.script] Script Log Level: Running script
17-04-24 13:40:43 INFO (MainThread) [homeassistant.helpers.script] Script Log Level: Executing step call service
17-04-24 13:40:43 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service=set_level, service_data=homeassistant.components=fatal, domain=logger, service_call_id=1978185328-103>
17-04-24 13:40:43 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=1978185328-102>
17-04-24 13:40:43 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=1978185328-103>
17-04-24 13:40:43 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: old_state=<state automation.log_level=on; last_triggered=2017-04-22T14:42:28.732226+00:00, friendly_name=Log Level @ 2017-04-23T12:41:34.190981-05:00>, new_state=<state automation.log_level=on; last_triggered=2017-04-24T13:40:43.616059-05:00, friendly_name=Log Level @ 2017-04-23T12:41:34.190981-05:00>, entity_id=automation.log_level>

image

My Configuration for Log Level Input Select

logger: 
log_level:
  name: Log Level
  options:
    - critical
    - fatal
    - error
    - warning
    - warn
    - info
    - debug
    - notset
  initial: warn
###################################
##  Dynamically set the log levels without having to restart HASS or edit configuration.yaml
#- Thanks @VDRainer
###################################

- alias: Log Level
  trigger:
    platform: state
    entity_id: input_select.log_level
  action:
    service: logger.set_level
    data_template:
      homeassistant.components: "{{ trigger.to_state.state }}"
CCOSTAN commented 7 years ago

Yes. it works for me instantly in the realtime logs. sudo journalctl home-assistant -fu

brianjking commented 7 years ago

@CCOSTAN

pi@hasspi3:~ $ sudo journalctl home-assistant -fu
journalctl: option requires an argument -- 'u'
CCOSTAN commented 7 years ago

sudo journalctl -u home-assistant -f

brianjking commented 7 years ago
Apr 24 14:51:18 hasspi3 hass[11467]: 17-04-24 14:51:18 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 1798708208: Sending {'id': 2, 'type': 'event', 'event': {'data': {'old_state': <state input_select.log_level=warn; friendly_name=Log Level, options=['critical', 'fatal', 'error', 'warning', 'warn', 'info', 'debug', 'notset'] @ 2017-04-24T14:35:28.560626-05:00>, 'entity_id': 'input_select.log_level', 'new_state': <state input_select.log_level=critical; friendly_name=Log Level, options=['critical', 'fatal', 'error', 'warning', 'warn', 'info', 'debug', 'notset'] @ 2017-04-24T14:51:18.319714-05:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2017, 4, 24, 19, 51, 18, 319886, tzinfo=<UTC>), 'event_type': 'state_changed'}}
Apr 24 14:51:18 hasspi3 hass[11467]: 17-04-24 14:51:18 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 1820938192: Sending {'id': 2, 'type': 'event', 'event': {'data': {'old_state': <state input_select.log_level=warn; friendly_name=Log Level, options=['critical', 'fatal', 'error', 'warning', 'warn', 'info', 'debug', 'notset'] @ 2017-04-24T14:35:28.560626-05:00>, 'entity_id': 'input_select.log_level', 'new_state': <state input_select.log_level=critical; friendly_name=Log Level, options=['critical', 'fatal', 'error', 'warning', 'warn', 'info', 'debug', 'notset'] @ 2017-04-24T14:51:18.319714-05:00>}, 'origin': 'LOCAL', 'time_fired': datetime.datetime(2017, 4, 24, 19, 51, 18, 319886, tzinfo=<UTC>), 'event_type': 'state_changed'}}
Apr 24 14:51:18 hasspi3 hass[11467]: 17-04-24 14:51:18 INFO (MainThread) [homeassistant.components.automation] Executing Log Level
Apr 24 14:51:18 hasspi3 hass[11467]: 17-04-24 14:51:18 INFO (MainThread) [homeassistant.core] Bus:Handling <Event logbook_entry[L]: message=has been triggered, entity_id=automation.log_level, name=Log Level, domain=automation>
Apr 24 14:51:18 hasspi3 hass[11467]: 17-04-24 14:51:18 INFO (MainThread) [homeassistant.helpers.script] Script Log Level: Running script
Apr 24 14:51:18 hasspi3 hass[11467]: 17-04-24 14:51:18 INFO (MainThread) [homeassistant.helpers.script] Script Log Level: Executing step call service
Apr 24 14:51:18 hasspi3 hass[11467]: 17-04-24 14:51:18 INFO (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: service_data=homeassistant.components=critical, service_call_id=1978632720-12, domain=logger, service=set_level>