PiotrMachowski / Home-Assistant-custom-components-Google-Keep

This sensor uses gkeepapi library to download a list of notes from https://keep.google.com/.
MIT License
66 stars 8 forks source link

Update for Sensor Fails #9

Closed austwhite closed 4 years ago

austwhite commented 4 years ago

I have just started noticing this since updating to Home Assistant 0.109.x I am unsure if it was present before as I had not kept a close eye on the logs. Getting an error "Update for sensor sensor.google_keep_xxxxx fails" fairly regularly.

Logger: homeassistant.helpers.entity
Source: custom_components/google_keep/sensor.py:85
First occurred: 4:22:37 PM (1 occurrences)
Last logged: 4:22:37 PM

 Update for sensor.google_keep_30d2008fe5 fails

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 472, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  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/google_keep/sensor.py", line 85, in update
    self._keep.sync()
  File "/usr/local/lib/python3.7/site-packages/gkeepapi/__init__.py", line 1019, in sync
    labels=[i.save() for i in self._labels.values()] if labels_updated else None,
  File "/usr/local/lib/python3.7/site-packages/gkeepapi/__init__.py", line 359, in changes
    json=params
  File "/usr/local/lib/python3.7/site-packages/gkeepapi/__init__.py", line 221, in send
    response = self._send(**req_kwargs).json()
  File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Any advice on what may be causing this?

Edit: Should have noted, I have installed the component via HACS and it is at version 1.0.0. HACS does not report any update available for the component.

remdot commented 4 years ago

I'm getting the same error, started this morning.

yguns31 commented 4 years ago

I just tried installing this integration last night for the first time and saw the same errors in the logs as you have.

yguns31 commented 4 years ago

According to this thread: https://github.com/kiwiz/gkeepapi/issues/83, the issue appears to be Google rejecting requests with gkeepapi in the User Agent. It appears gkeepapi has been updated recently to fix this. Does anybody know how to update to the most recent gkeepapi. I'm not too familiar with python.

ChocoTonic commented 4 years ago

what do you all use this API for? @austwhite @remdot @yguns31

wizpig64 commented 4 years ago

Does anybody know how to update to the most recent gkeepapi.

@yguns31 Assuming you installed with pip in the first place, you could do:

pip install --upgrade gkeepapi
austwhite commented 4 years ago

@ChocoTonic I use the API for lists / google keep.

I can't use pip to update as I am using Home Assistant (Previously HASSIO) on a Raspberry Pi 3B+ and using HACS to install the this integration.

austwhite commented 4 years ago

I noted the issue only seems to have started since updating Home Assistant, but I didn't check the logs much in 0.108.x. The latest HA's have had a lot of patches so I tend to wait for a bit before updating.

yguns31 commented 4 years ago

The latest version (0.11.14) of gkeepapi has fixed the issue. Changing the requirements in the manifest.json from "gkeepapi" to "gkeepapi==0.11.14" should allow the integration to work again.

austwhite commented 4 years ago

@yguns31 I use Home Assistant (formerly Hassio). How did you change the API or is this something that still needs a permanent fix by the developer?

matisaul commented 4 years ago

The latest version (0.11.14) of gkeepapi has fixed the issue. Changing the requirements in the manifest.json from "gkeepapi" to "gkeepapi==0.11.14" should allow the integration to work again.

@yguns31 Hi! I tried to do that, but it doesn't work...

bevosangryghost commented 4 years ago

@yguns31 Thanks, that fixed it for me.

PiotrMachowski commented 4 years ago

I have upgraded used version of gkeepapi, it should fix this issue

austwhite commented 4 years ago

Confirmed that bug is fixed