sander1988 / Indego

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

Invalid config #12

Closed jjanderson closed 5 years ago

jjanderson commented 5 years ago

Hi,

After upgrading I get this:

`Log Details (ERROR)
Tue Aug 13 2019 09:58:58 GMT+0100 (GMT+01:00)
Error during setup of component indego
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 387, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 383, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.7/http/client.py", line 1336, in getresponse
    response.begin()
  File "/usr/local/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.7/http/client.py", line 267, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 317, in recv_into
    raise timeout('The read operation timed out')
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 641, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 368, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 686, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 603, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 389, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 307, in _raise_timeout
    raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.indego.iot.bosch-si.com', port=443): Read timed out. (read timeout=30)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 172, 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 54, in setup
    Mower()
  File "/config/custom_components/indego/__init__.py", line 104, in __init__
    IndegoAPI_Instance.getOperatingData()
  File "/usr/local/lib/python3.7/site-packages/pyIndego/__init__.py", line 365, in getOperatingData
    tmp_json = self.get(complete_url)
  File "/usr/local/lib/python3.7/site-packages/pyIndego/__init__.py", line 839, in get
    response = requests.get(url, headers=headers, timeout=30)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.indego.iot.bosch-si.com', port=443): Read timed out. (read timeout=30)`
Shamshala commented 5 years ago

Exactly same for me but i wasn't confident enough if it isn't just my mistake. :D

jm-73 commented 5 years ago

IT seems like the HTTPS call to Bosch API is making a timeout. I have to figure out a way to be able to trigger this error myself in order to come up with a solution...

jm-73 commented 5 years ago

Home Assistant or Hassio? Version of HA? Model of mower? Version of the component?

jjanderson commented 5 years ago

It could be because the mower is turned off? @Shamshala can you confirm if your mower is powered on?

In terms of questions:

Home Assistant or Hassio? --> Hassio (Intel NUC Build) System: HassOS 2.12 Deployment: production Hass.io supervisor Version: 173

Version of HA? --> 0.97.2 Model of mower? --> 350 Connect Version of the component? --> 0.6 (2019-08-11)

jm-73 commented 5 years ago

Some of the API calls wakes the mower up and asks the mower for information. So it could be that kind of API calls that does a timeout. Good input!

jjanderson commented 5 years ago

My mower is powered off.... it has a mind of it's own most of the time, the map does not save (error 410 - which I am waiting for Bosch to resolve...)

So if the API requires a response from the mower itself, it will timeout as the mower will not wake... I have phyisically powered it off on the mower switch, but it is docked...

jm-73 commented 5 years ago

I have added a feature request under Project that I will implement time-out handling when the Bosch API dont give an answer. If you could try with your mower turned on for just a few minutes? Then we are sure that this is the issue?

jjanderson commented 5 years ago

I will try when I get home tonight....HOwever...

When I look here: http://grauonline.de/alexwww/indego/indego.html, I get updates on the states from the mower....

Time error state mowed runtime total (operate, charge) runtime session (operate, charge)  
2019-08-13-14:22:50   64513 / undefined 0 % 38 days 14:21, 15 days 06:55 00:32, 00:23  
2019-08-13-14:22:50           connect
2019-08-12-14:16:58   64513 / undefined 0 % 38 days 14:21, 15 days 06:55 00:32, 00:23  
2019-08-12-14:16:58           connect
2019-08-12-14:16:55            
2019-08-08-09:52:52   64513 / undefined 38 % 37 days 22:57, 15 days 02:08 02:24, 01:01  
2019-08-08-09:52:51           connect
Time error state mowed runtime total (operate, charge) runtime session (operate, charge)  
2019-08-13-14:22:50   64513 / undefined 0 % 38 days 14:21, 15 days 06:55 00:32, 00:23  
2019-08-13-14:22:50           connect
2019-08-12-14:16:58   64513 / undefined 0 % 38 days 14:21, 15 days 06:55 00:32, 00:23  
2019-08-12-14:16:58           connect
2019-08-12-14:16:55            
2019-08-08-09:52:52   64513 / undefined 38 % 37 days 22:57, 15 days 02:08 02:24, 01:01  
2019-08-08-09:52:51           connect
Shamshala commented 5 years ago

It could be because the mower is turned off? @Shamshala can you confirm if your mower is powered on?

Yep, my mower is turned off as well. But i didn't get such error until 0.3b or 0.5 (0.3 works ok). I have HassOS 3.3, HA 0.97.2 (but it doesn't work on older version), Supervisor 173, it's in ESXi virtual machine and my mower is 1200.

jm-73 commented 5 years ago

I understand. The responses you get when your mower is turned off is the cached response and states that the mower already sent to Bosch servers. I have noticed that some calls to the API wake the mower up if it is in sleep mode. That should mean that the mower is sending some kind of response to the API call. I havent had the time to figure out which of the API calls that wakes the mower yet. I think that the "/alms//operatingData" for example wakes the mower. If I am right, this API call should give a timeout...

jm-73 commented 5 years ago

The difference between the earlier releases as 0.3 and 0.5 is that it didnt have the API-call "operatingData". It is used for the battery sensors in the Indego.

jm-73 commented 5 years ago

I can also see in my log that this error occurs once. Even if my mower was online at the moment. And as the log says, it is the function getOperatingData that times out for both you and me.

jjanderson commented 5 years ago

OK, so after deleting my account, and then deleting the app, resetting my bot to factory settings. Signup for a new account, insert serial, map garden, and then I am still getting an error "Indego not mapped"

... that being said...

after rebooting HA with Indego in a ready state, the component seems to be back online.

jjanderson commented 5 years ago

and back in the room...

image

jjanderson commented 5 years ago

image

jm-73 commented 5 years ago

I really like your card! I havent had the time to make my HA that fancy... Is it hard?

jjanderson commented 5 years ago

I will post code on the HA Thread here: https://community.home-assistant.io/t/bosch-indego/25196/115

For now however I think this issue can be closed here, as long as there is a fix for the timeout / or when the mower cannot connect for some reason...

jjanderson commented 5 years ago

I really like your card! I havent had the time to make my HA that fancy... Is it hard?

a bit fiddly, especially if you consider spacing as well as dynamic variables... as you mentioned, there seem to be loads of status items, each with a different length (characters) which impacts how these are rendered.

the trick is not report everything, only the really useful items to the user (which can be configured via lovelace card interface)

What I would like to do before posting my code for ui:

  1. My buttons are input booleans with a script, I need to change this to call the service directly

  2. It would be great to use a slider card:

    • Home page (slide) as mine posted earlier with the picture card
    • Slide left: - Live map (or it would have to be a static image for now until we can expose the map via the API)

Anyway, feel free to dump this into you lovelace somewhere:

  1. place an image in the image url (MINE IS /local/icons/larry.png)
    • I also, in this code have a second card which is an image of the map, -- change this url from: /local/icons/garden_map.png TO SOMETHING ELSE
  2. change the icons to call the actual service

Here is the image I used:

larry

CREATE NEW LOVELACE CARD SOMEWHERE AND ENTER THIS CODE:

cards:
  - image: /local/icons/larry.png
    type: picture-elements
    elements:
      - type: state-label
        entity: sensor.indego_mower_alert
        suffix: ' Alerts'
        style:
          top: 12%
          left: 12%
          font-size: 15px
      - type: state-label
        entity: sensor.indego_lawn_mowed
        suffix: ' Complete'
        style:
          top: 26%
          left: 16%
          font-size: 15px
      - type: state-label
        entity: sensor.indego_battery
        prefix: 'Battery : '
        style:
          top: 40%
          left: 16%
          font-size: 15px
      - type: state-label
        entity: sensor.indego_mower_state_detail
        style:
          top: 54%
          left: 12%
          font-size: 15px
      - type: state-label
        entity: sensor.indego_runtime_total
        prefix: 'Runtime : '
        style:
          top: 82%
          left: 17%
          font-size: 15px
      - type: state-label
        entity: sensor.indego_mowing_mode
        prefix: 'Mode : '
        style:
          top: 68%
          left: 18%
          font-size: 15px
      - type: icon
        title: Mow
        icon: 'mdi:play'
        entity: input_boolean.indego_mow
        tap_action:
          action: toggle
        style:
          top: 15%
          left: 70%
          '--iron-icon-fill-color': '#FFFFFF'
          '--iron-icon-height': 40px
          '--iron-icon-width': 40px
      - type: icon
        title: Pause
        icon: 'mdi:pause'
        entity: input_boolean.indego_pause
        tap_action:
          action: toggle
        style:
          top: 15%
          left: 83%
          '--iron-icon-fill-color': '#FFFFFF'
          '--iron-icon-height': 40px
          '--iron-icon-width': 40px
      - type: icon
        title: Home
        icon: 'mdi:home'
        entity: input_boolean.indego_home
        tap_action:
          action: toggle
        style:
          top: 15%
          left: 95%
          '--iron-icon-fill-color': '#FFFFFF'
          '--iron-icon-height': 40px
          '--iron-icon-width': 40px
      - type: state-label
        entity: sensor.indego_mower_state
        prefix: 'State : '
        style:
          top: 32%
          left: 88%
          font-size: 15px
  - image: /local/icons/garden_map.png
    type: picture-elements
    aspect_ratio: 50%
    elements:
      - type: state-label
        entity: sensor.indego_battery_v
        prefix: 'Battery v : '
        style:
          top: 52%
          left: 18%
          font-size: 15px
type: 'custom:vertical-stack-in-card'
jjanderson commented 5 years ago

oh, and also take not of the requirements from the custom cards (liketype: 'custom:vertical-stack-in-card'