Netatmo Welcome Camera

It seems now feasible as the API is open and similar to the one used for the weather station

I decided to work on it myself. I can’t give any ETA as it will be my first dev (Might takes weeks or months :wink: )

So I started my work here what I plan to do with the Welcome Camera:

  • Rework of the NetAtmo API to became a global component (done)
  • Camera device (of course) using MJPEG standard (almost done)
  • Binary Sensor device (to detect if someone know or unknown has been detected)
  • “Device tracker” (as the camera can say if someone is at home or not)

I’ll focus my work first of all on the API and the camera component, then the sensor to finish with the “device tracker”

I submitted the first pull request for the Welcome Camera (https://github.com/home-assistant/home-assistant/pull/2233), it will provide access to the live of the camera.

Binary sensors (to detect movement, (un)known persons seen…) will come in a next pull request

I,m trying to add support for the Netatmo thermostat. It works, but i have a problem with updating the values, and i can’t change settings.
Can you integrate the thermostat in your netatmo component?

As I don’t have a Netatmo Thermostat it will be difficult to me to help you on that, but my updated netatmo is designed to provide credentials to all netatmo device (Weather station, Camera and Thermostat). you can look at my changes here: https://github.com/home-assistant/home-assistant/pull/2233

I already found your changes, but it is the first time i’m trying something like this.
Maybe you can help me if I gave you my credits?

No, never share your credentials with someone that you don’t know, but I think, you can add me as user in the Netatmo config panel (in your app, or on the website) then I will have access to your thermostat through my account but you can revoke my access at anytime (my mail [email protected])

invitation send

The first feature for Netatmo Welcome (live feed) has been merged to home-assistant, for the other feature (binary sensors and tracker) I’ve to postpone a little bit the dev because I’m currently under water, so I can’t get some time to work on really interesting thing

Hi all,

I’ve been quiet in the latest weeks as I moved to my new home and then I took some holidays, but I’m back to continue my work on the Netatmo Welcome camera, the next step will be to introduce binary sensor based on camera events (person known seen, person unkown seen, motion…) so we can use them as trigger for scripts.

any update on that topic ? if I can help…

The binary sensor is now fully developed and should be release with Home-Assistant 0.31. The support for the welcome tags will come later.

The next step will be to use the camera as a “device” tracker, but no idea for the ETA

@jabesq
Do you have any plans for the new Netatmo presence?

Is it possible to use webhooks https://dev.netatmo.com/dev/resources/technical/reference/cameras/addwebhook
To update events

Hi @gieljnssns, Apparently the Netatmo Presence uses almost the same API than the Welcome camera so it might work, but I don’t have one I can be sure.

It is possible to the webhooks (nothing is impossible :wink: ) but it would require a full rework of the netatmo components and also create a configuration panel in order to easily setup the webhook url.

@jabesq
I think using webhooks is needed,
because when I make 4 more binary sensors for the presence (outdoor motion, human seen, animal seen, vehicle seen) and I implement them like you did, we are going to exceed the limit of api-calls.
But I really don’t know how to use a webhook in HA.
Maybe you know a way?

A way to avoid the limit of API-Calls is to add throttling mechanism to updateEvent function inside netatmo-api-python (we can limit the calls to every 10sec). Currently do you have a specific error when reaching the limit of API calls
Regarding of webhook, I don’t know exactly how to use it in HA, but I saw that the Fitbit component (and maybe other component) are using it in order to retrieve information.

16-11-30 14:04:00 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)
  File "/Users/giel/Github/home-assistant/homeassistant/helpers/entity_component.py", line 386, in _update_entity_states
    yield from update_coro
  File "/Users/giel/Github/home-assistant/homeassistant/helpers/entity.py", line 213, in async_update_ha_state
    yield from self.hass.loop.run_in_executor(None, self.update)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/home-assistant/homeassistant/components/binary_sensor/netatmo.py", line 177, in update
    self._data.welcomedata.updateEvent(home=self._data.home)
  File "/Users/giel/.homeassistant/deps/smart_home/Welcome.py", line 191, in updateEvent
    resp = postRequest(_GETEVENTSUNTIL_REQ, postParams)
  File "/Users/giel/.homeassistant/deps/smart_home/__init__.py", line 25, in postRequest
    resp = urllib.request.urlopen(req, params).read(body_size).decode("utf-8")
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 582, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 510, in error
    return self._call_chain(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 590, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

@jabesq
I have implemented an API-call counter in init.py:

def apiCall():
    global _API_CALL_COUNTER
    _API_CALL_COUNTER += 1
    print(_API_CALL_COUNTER)
    return _API_CALL_COUNTER

after every api-call in the netamo module:

resp = postRequest(_GETHOMEDATA_REQ, postParams)
apiCall()

I’m using the thermostat and my presence
after 40min

496
497
498
499
500
501
16-12-01 13:30:01 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)
  File "/Users/giel/Github/home-assistant/homeassistant/helpers/entity_component.py", line 386, in _update_entity_states
    yield from update_coro
  File "/Users/giel/Github/home-assistant/homeassistant/helpers/entity.py", line 213, in async_update_ha_state
    yield from self.hass.loop.run_in_executor(None, self.update)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/giel/Github/home-assistant/homeassistant/components/binary_sensor/netatmo.py", line 177, in update
    self._data.welcomedata.updateEvent(home=self._data.home)
  File "/Users/giel/.homeassistant/deps/smart_home/Welcome.py", line 189, in updateEvent
    resp = postRequest(_GETEVENTSUNTIL_REQ, postParams)
  File "/Users/giel/.homeassistant/deps/smart_home/__init__.py", line 26, in postRequest
    resp = urllib.request.urlopen(req, params).read(body_size).decode("utf-8")
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 472, in open
    response = meth(req, response)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 582, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 510, in error
    return self._call_chain(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/urllib/request.py", line 590, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden
^C16-12-01 13:30:10 INFO (MainThread) [homeassistant.core] Bus:Handling <Event homeassistant_stop[L]>