How do you override default components?

So I have daikin ac units that are manually added to the config and they are found and actually work well. The problem comes when I try to command them via google assistant which is configured directly via cloud. I did a SYNC call and part of the hass answer is below:

DEBUG (MainThread) [homeassistant.components.cloud.iot] Publishing message:
        {'msgid': 'ac2021ba7-fd63-4cf2-a115-ffaebab239ab30',
         'payload': {'payload': {'agentUserId': 'b532c9d3-8ba6-483a-b52f-737d0145179df8d',
                                 'devices': [
                                             //some other devices
                                             {'attributes': {'availableThermostatModes': '',
                                                             'thermostatTemperatureUnit': 'C'},
                                              'id': 'climate.living',
                                              'name': {'name': 'living'},
                                              'traits': ['action.devices.traits.TemperatureSetting'],
                                              'type': 'action.devices.types.THERMOSTAT',
                                              'willReportState': False} 
                                              //some other devices
                                     ]},
                         'requestId': '9093337730955027507'}}

Now the problem lies I think in the fact that availableThermostatModes is empty because no matter what command I give to the google assistant it tells me that mode is not supported, so I cannot change the temperature or put the ac in any mode(basically I cannot turn it on or off). The only thing I can do is ask for the temperature but since the thermostatTemperatureAmbient is available on the response that is presented correctly.

Example of response when asking for the temperature:

DEBUG (MainThread) [homeassistant.components.cloud.iot] Publishing message:
{'msgid': '7314205cf3-a5a2-4b1b-af4d-2a3607208278e',
 'payload': {'payload': {'devices': {'climate.living': {'online': True,
                                                        'thermostatTemperatureAmbient': 27.0,
                                                        'thermostatTemperatureSetpoint': 21.0}}},
             'requestId': '99898141249264436591213'}}

So I tried adding logging to google_assistant/trait.py in the sync_attributes method to see what modes come set from the daykin climate component, but while putting that in the custom components it does not overwrite the default one since I am not seeing any debugger messages and I do have the debugging enabled for the component via homeassistant.components.google_assistant: debug

So what am I missing ? How can I override trait.py and better debug things ? Is there like a port that I can connect to with a python debugger ? What is the best way to debug and improve components ?

You need to put it at <config>/custom_components/google_assistant/trait.py.

I did add it there. But I only added that file so maybe the SYNC does not go through that component. Do I need to add all the files from the component there ?

You should first check the HA log to see if your custom component is getting loaded. E.g., in my case:

pi@raspberrypi:/home/homeassistant/.homeassistant $ grep Loaded home-assistant.log | grep custom_components
2018-08-08 19:09:03 INFO (MainThread) [homeassistant.loader] Loaded device_tracker.life360 from custom_components.device_tracker.life360
2018-08-08 19:09:04 INFO (MainThread) [homeassistant.loader] Loaded sensor.illuminance from custom_components.sensor.illuminance
2018-08-08 19:09:04 INFO (MainThread) [homeassistant.loader] Loaded sun from custom_components.sun
2018-08-08 19:09:15 INFO (MainThread) [homeassistant.loader] Loaded camera.amcrest from custom_components.camera.amcrest
2018-08-08 19:09:16 INFO (MainThread) [homeassistant.loader] Loaded binary_sensor.amcrest from custom_components.binary_sensor.amcrest

But do you have debug enabled for custom_components.google_assistant.trait?

Thanks, will check that when I get home. Aaaah I see, so custom_components != homeassistant.components. I thought that being overridden from custom the structure remains the same.

If you’re interested, I have a Python script I wrote that extracts all components that have written into home-assistant.log and generates a list of these component names & the logging severity (i.e., INFO, DEBUG, etc.), sorted by the number of lines they have written, with a total number of lines as well. The output looks like this:

homeassistant.components.zwave.util DEBUG 1888
openzwave DEBUG 670
homeassistant.core INFO 660
homeassistant.components.automation INFO 85
homeassistant.setup INFO 85
homeassistant.util.json DEBUG 64
homeassistant.loader INFO 62
homeassistant.components.automation DEBUG 42
nest.nest DEBUG 26
homeassistant.components.history DEBUG 24
sseclient DEBUG 22
homeassistant.helpers.script INFO 21
homeassistant.components.recorder.util DEBUG 13
homeassistant.components.nest DEBUG 12
homeassistant.components.sensor INFO 11
homeassistant.components.http.view INFO 11
homeassistant.components.zwave DEBUG 7
homeassistant.components.binary_sensor INFO 7
custom_components.device_tracker.life360 DEBUG 6
homeassistant.loader WARNING 6
homeassistant.components.zwave INFO 5
homeassistant.components.switch INFO 4
homeassistant.components.media_player.cast DEBUG 4
homeassistant.components.binary_sensor.ping DEBUG 4
homeassistant.components.light.zwave DEBUG 4
pychromecast.socket_client DEBUG 4
openzwave INFO 3
homeassistant.components.camera INFO 3
homeassistant.components.notify INFO 2
custom_components.camera.amcrest DEBUG 2
homeassistant.components.light INFO 2
custom_components.sensor.illuminance DEBUG 2
homeassistant.helpers.restore_state DEBUG 2
nest.nest INFO 2
pychromecast.controllers DEBUG 2
homeassistant.components.recorder DEBUG 1
homeassistant.bootstrap INFO 1
root DEBUG 1
pychromecast INFO 1
homeassistant.components.device_tracker INFO 1
homeassistant.components.recorder.util ERROR 1
homeassistant.components.climate INFO 1
homeassistant.components.media_player INFO 1
total: 3775

You can use this information to decide what to exclude/include in your log via the logger configuration parameter. You can also see what components are actually writing to the log.

It’s simple to use. Just place a copy in your HA configuration directory, and run it like this:

python3 logcomps.py

Here is the script (logcomps.py):

import re

p = re.compile(r'\d+-\d+-\d+\s+\d+:\d+:\d+\s+([A-Z]+)[^[]*\[([^]]+)\]')
comps = {}
n_comps = 0
for line in open('home-assistant.log').readlines():
    m = p.match(line)
    if m:
        comp = (m.group(2), m.group(1))
        comps[comp] = comps.get(comp, 0) + 1
        n_comps += 1
for comp in sorted(comps.items(), key=lambda x: x[1], reverse=True):
    print(comp[0][0], comp[0][1], comp[1])
print('total:', n_comps)
1 Like