Testers wanted - Netatmo integration

thank you for quick fixing
Regardin the map - No I haven’t map configured. I can see map in the HA area so wasn’t expecting anything more must be done.

Anyway showing option to enable map while the map is unavailable due to configuration cam be misleading. Maybe some notification about the need of enabling the map could be helpful for generic user.

with regards

Likely found the bug.
After adding the integration I repeated setting options in order to set custom coordinates of area.
After accepting setting everything were working for several days. Yesterday I restarded HA but this time the integration failed to work.

Below sceenshot of coordinates set as well as log records


Logger: homeassistant.components.sensor
Source: custom_components/netatmo/pyatmo/auth.py:167 
Integration: Sensor (documentation, issues) 
First occurred: 12:59:49 AM (1 occurrences) 
Last logged: 12:59:49 AM

Error while setting up netatmo platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/config/custom_components/netatmo/sensor.py", line 197, in async_setup_entry
    await add_public_entities()
  File "/config/custom_components/netatmo/sensor.py", line 172, in add_public_entities
    area_name=area.area_name,
  File "/config/custom_components/netatmo/data_handler.py", line 133, in register_data_class
    DATA_CLASSES[data_class_name], data_class_entry, **kwargs
  File "/config/custom_components/netatmo/data_handler.py", line 106, in async_fetch_data
    partial(data_class, **kwargs), self._auth,
  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/netatmo/pyatmo/public_data.py", line 66, in __init__
    resp = self.auth.post_request(url=_GETPUBLIC_DATA, params=post_params)
  File "/config/custom_components/netatmo/pyatmo/auth.py", line 167, in post_request
    f"{resp.status_code} - "
pyatmo.exceptions.ApiError: 400 - Bad request - Invalid coordinates given (21) when accessing 'https://api.netatmo.com/api/getpublicdata'

Which version of the custom component do you have installed?

Hello
HACS shows 05e1770.
Now I can see there is some update pending (my fault I didn’t check it before). Does it fix this issue?

Found the issue, the coordinates are mixed up. I’ll catch that in the code. Will push a fix later. Check your longitudes.

Hmm. I just put those numbers to google maps and seems those are correct.

Long East must be a larger number than Long West and Lat North larger than Lat South.

Ahh. You are right. This is written in field descriptions indeed.
you know… designating a rectangle requires 2 points in random order :wink: It must be the reason I ignored this requirement.
Maybe it’s good idea to consider this fact at time of improving the UI.

Thanks for your work.

1 Like

It’s a good find though. I can catch that mistake in the code. A UI location picker is in the making (no ETA).

So with the latest changes mixed up coordinates should be a thing of the past.

Exchanged coordinates, updated the integration to version: d4ce7c5
I admit I shouldn’t do two changes at once…

After restart all endities are doubled. Clickings on each entity shows info that this is an orphan…

BTW it’s impossible to select the message with mouse (to copy&paste)… Someone had to put a lot of effort to disallow basic operation which is selecting the text in browser :wink:

Error doing job: Task exception was never retrieved

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 449, in _async_add_entity
    await entity.async_added_to_hass()
  File "/config/custom_components/netatmo/sensor.py", line 531, in async_added_to_hass
    await super().async_added_to_hass()
  File "/config/custom_components/netatmo/netatmo_entity_base.py", line 59, in async_added_to_hass
    self.async_update_callback()
  File "/config/custom_components/netatmo/sensor.py", line 579, in async_update_callback
    if self._data is None:
  File "/config/custom_components/netatmo/sensor.py", line 527, in _data
    return self.data_handler.data[self._signal_name]
KeyError: 'PublicData-b4104c82-2780-4574-8398-b11c004f7d24'

Could you tell me the exact steps to replicate this?

During a day I’ve replaced coordinates as discussed before. Currently those looks like this:

Then after coming home, I updated NetAtmo component from HACS (as requested by HACS) and performed HA restart.

Could you try to replicate this with the current version?

What do you mean by current version?
I have installed d4ce7c5. HACS doesn’t indicate there is newer one.

Sorry, that’s what I meant.

What’s implemented now is the prevention of entering mixed up coordinates. It wont fix existing entries. I can’t get it to fail no matter how often I restart, create and delete stations. :wink: I had this once when I was in the middle of fixing this, so this might be the case of an existing entry with wrong coordinates that can’t be established. Shouldn’t be possible any more.

OK thanks for answer.
Pity there is no easy way how to resolve such issues (beacuse all entities are marked as orphans.
At the end I removed integration (in Configuration/Integrations section) and re-added it again.

BTW I’ve noticed that the sensor handling 1-hour sum of rain changed the name. Previously its name contained ‘1h’ (the same way as 24h sensor has). Right now it contain ‘hour’ word.

You could have removed those orphans from the entities panel.

About the renaming, I noticed that it had no pretty names but ones like sum_rain_24, that’s why I changed them. Well spotted though.

Here are my test results:

  • Overall robustness → integration is working fine
  • Turning the light switch on and off is reacting very quickly
  • When the light on the camera is turned on due to movement, the status of the light entity in HA is not changing to on. Is that data available in the API?
  • Is the brightness of the light part of the API? Because then the brightness_level could also be used in HA.