sander1988 / Indego

Home Assistant Custom Component for Bosch Indego Lawn Mower
Apache License 2.0
96 stars 29 forks source link

0.4b: Error during setup of component indego #6

Closed onkelfarmor closed 5 years ago

onkelfarmor commented 5 years ago

Get this error after copying the new files to my folder and restarting HA.

Error during setup of component indego
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 156, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/indego/__init__.py", line 68, in setup
    IndegoAPI_Instance = IndegoAPI(username=mower_username, password=mower_password, serial=mower_serial)
  File "/config/custom_components/indego/__init__.py", line 177, in __init__
    self.update()
  File "/config/custom_components/indego/__init__.py", line 318, in update
    self.getGenericData()
  File "/config/custom_components/indego/__init__.py", line 526, in getGenericData
    self._alm_name = tmp_json['alm_name']
KeyError: 'alm_name'
jm-73 commented 5 years ago

Are there any other info about the component before this rows in your log? Version of HA? Did you do a restart of Hassio or HA?

onkelfarmor commented 5 years ago

nope :-(

jm-73 commented 5 years ago

If you do another reboot? If you try to delete the __pycache__ in your Indego folder before reboot?

jm-73 commented 5 years ago

I have tested with a fresh install of hassio 0.96.5 right now. Cant reproduce your error. Also running without error messages in my development environment as well as my "real" Hassio. So I need more information from you in order to solve this.

onkelfarmor commented 5 years ago

Tried everything.

Using hassio 0.65.5

onkelfarmor commented 5 years ago

I forgot to write, that I also get this error in the frontend:

The following components and platforms could not be set up:

indego
Please check your config.

But I haven't changed my config, so it looks like it now expects something ells from the config - don't see any changes about that in the instruction.

nsimb commented 5 years ago

also got error setting it up after the update. Let me know if you need anything

Thanks for the hard work to get this component updated, got really happy when I did see someone did pickup and further develop the component

jm-73 commented 5 years ago

Hmmm, very strange. The only thing I need is the log file. But if it says nothing more than you stated here, then it is not of any use.

@nsimb : What version of Hassio are you running? Or are you running HA?

nsimb commented 5 years ago

Home Assistant 0.96.5 Hass.io 170 HassOS 2.12

Tue Aug 06 2019 12:51:05 GMT+0200 (centraleuropeisk sommartid) Error during setup of component indego Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 156, in _async_setup_component component.setup, hass, processed_config) # type: ignore File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/indego/init.py", line 68, in setup IndegoAPI_Instance = IndegoAPI(username=mower_username, password=mower_password, serial=mower_serial) File "/config/custom_components/indego/init.py", line 177, in init self.update() File "/config/custom_components/indego/init.py", line 317, in update self.getUsers() File "/config/custom_components/indego/init.py", line 507, in getUsers self._optinapp = tmp_json['optInApp'] KeyError: 'optInApp'

jm-73 commented 5 years ago

The interesting part is that you got different kind of errors. The error indicates that the json answer doesnt contain the expected values. I think I have to add some error handling as my component handles the json answers very static.

jm-73 commented 5 years ago

You have tried the debug log?

logger:
  logs:
    custom_components.indego: debug
jm-73 commented 5 years ago

If you are comfortable with changing in your component code, please change the following:

@onkelfarmor __init__.py row 526: self._alm_name = tmp_json['alm_name'] to self._alm_name = tmp_json.get('alm_name')

@nsimb __init__.py row 507: self._optinapp = tmp_json['optInApp'] to self._optinapp = tmp_json.get('optInApp')

If you could try this and see if the error moves to another row, that would be of great help to me. If this json string handling is fixing the error, then I could release a new beta that is corrected.

onkelfarmor commented 5 years ago

I changed row 526 as described and now get a new error, so yes, it moves to a another row:

Error during setup of component indego
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 156, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/indego/__init__.py", line 68, in setup
    IndegoAPI_Instance = IndegoAPI(username=mower_username, password=mower_password, serial=mower_serial)
  File "/config/custom_components/indego/__init__.py", line 177, in __init__
    self.update()
  File "/config/custom_components/indego/__init__.py", line 319, in update
    self.ModelDescription()
  File "/config/custom_components/indego/__init__.py", line 826, in ModelDescription
    return self._model_description
AttributeError: 'IndegoAPI' object has no attribute '_model_description'
jm-73 commented 5 years ago

Ok, good. My theory works then!

You could try to continue changing all the locations that gives you an error. Or you could wait for an updated beta from me with this error control in all json handling.

onkelfarmor commented 5 years ago

Would love to do it myself, but need more guidance :-) or I just wait for you.

Very happy about your work!

jm-73 commented 5 years ago

There is another beta tagged as 0.4b2. It is only the __init__.py' that is updated with the new json handling. So it should be enough to just replace this file, restart and look in the log file...

onkelfarmor commented 5 years ago

Updated, I now don't get any errors but don't know how to at what to look for in the log.

jm-73 commented 5 years ago

See if your sensors are working. Other than that, look for errors in the log. Are your sensors showing as expected?

onkelfarmor commented 5 years ago

After some restarts and some retries, I now get the same warning, that Indego not could be setup and the same error in the log as above. No sensors working.

onkelfarmor commented 5 years ago

Found an error in init.py, line 811:

return self._model_description

must be

return self.model_description

now I get more sensors showing up, but they are not updated with data. However, in the log I see that all data is collected from Bosch, but it is somehow not written to the sensor.

Update (1): The same error was in line 404: _LOGGER.debug(f"self._model_description = {self.model_description}")

I now have sensor.indego_batt_voltage sensor.indego_battery sensor.indego_lawn_mowed sensor.indego_mowing_mode sensor.indego_runtime_total working.

Missing, state, update and alerts.

Update (2): Same error in sensor.py line 117 - after fix I now see state, but still miss the last two sensors (update and alerts).

Another thing - have an automation sending me a push notification each time mower percent changes - it have been working until this beta, now I get a notification each minute. The percent is the same each time :-)

nsimb commented 5 years ago

If you are comfortable with changing in your component code, please change the following:

@onkelfarmor __init__.py row 526: self._alm_name = tmp_json['alm_name'] to self._alm_name = tmp_json.get('alm_name')

@nsimb __init__.py row 507: self._optinapp = tmp_json['optInApp'] to self._optinapp = tmp_json.get('optInApp')

If you could try this and see if the error moves to another row, that would be of great help to me. If this json string handling is fixing the error, then I could release a new beta that is corrected.

Looks like I missed allot (sorry was away) Will try to test the new version this afternoon

nsimb commented 5 years ago

did install the new version, did however not do the manual changes @onkelfarmor did (since my setup worked fine with the _ in "return self._model_description" Looks like this ones are working: sensor.indego_batt_voltage sensor.indego_battery sensor.indego_lawn_mowed sensor.indego_mower_state sensor.indego_mowing_mode sensor.indego_runtime_total Alerts, update are not available, same as @onkelfarmor missing

not sure if its might to this in sensor.py: '#' mower_alert_sensor_name = CONF_MOWER_NAME + ' mower alert' '#' add_devices([IndegoAlertSensor(mower_alert_sensor_name)])

update: I did turn on the debug log and looked at it. To be honest, based on it I can't really tell but I don't see any errors or problem with either "update" or "Alerts" so I don't think the code is not executing this parts. (I am no developer or coder, so please don't go on my assumptions too much) I have saved the HA log and can send it to you if you need it

jm-73 commented 5 years ago

The alerts was commented out because I was experiencing strange errors with the API-calls. I think it is related to UTF8-encoding as my alerts are in swedish (containing swedish special characters).

I have worked on new code to implement the new PYPI API. I will not add any more time on the beta as it takes time from pushing towards the release of a better coded component.

jm-73 commented 5 years ago

Closed when 0.5 is released.