How to trigger automation on event sent by netatmo presence camera?

Hi,
Despite reading the different documentation pages and trying a bunch of different set ups, I still can’t figure out how to trigger an automation based on an event fired by my Netatmo Presence camera…
So far I have the following automation:

- id: Movement Detected
  alias: mouvement détecté
  trigger:
  - platform: event
    event_type: netatmo_movement
  - platform: event
    event_type: netatmo_person
  - platform: event
    event_type: netatmo_other
  action:
  - data:
      message: mouvement détecté
    service: notify.google_push_pixel_2

and configuration:

netatmo:
  api_key: !secret netatmo-api-key
  secret_key: !secret netatmo-secret
  username: !secret email
  password: !secret netatmo-password
  discovery: true
  webhooks: true

Any idea what i’m doing wrong?
Thanks in advance
V.

Did you try whether the events fire in the Developer Tools > Events section? At the bottom there is a tool to subscribe to events and show when they fire. I just gave it a quick go and it worked just fine. I just tested with event type netatmo_movement .

image

As usual, kudos for the reactivity!
I’ll try your suggestion to verify whether events are fired.

Once the event is caught, is there any way to retrieve the snapshot corresponding to the event? I saw there is a getCameraPicture in the pyatmo api, but I’m not sure whether a corresponding call is implemented in the netatmo component.

After spending a moment walking around in front of the camera, no event is caught by the listener… firing the event manually from the same page does work and the event is caught.

Are you a nabu casa user?
Which events did you try? netatmo_movement did work pretty well, so did netatmo_person.

I’m not using nabu casa, but the duckdns addon with ssl on hassio. I’ve set the url in the configuration. The Boolean triggers work well, just not the events…

Did you check at the Netatmo dev portal?
Maybe your webhook is banned…

I have created a second app at the dev portal.
Filled in webhook url:
https://xxxxxxxxxxxxx.duckdns.org/api/webhook/{webhook_id}

Then created an automation

  alias: Netatmo Webhook
  initial_state: 'on'
  trigger:
    platform: webhook
    webhook_id: {webhook_id}
  action:
    - service: mqtt.publish
      data_template:
        topic: 'netatmo/update'
        retain: true
        payload_template: >
           {{ trigger.json | tojson }}

And then some mqtt sensors, one for type:

- platform: mqtt
  name: Netatmo webhook trigger
  state_topic: 'netatmo/update'
  expire_after: 20
  value_template: '{{ value_json.push_type  }}'

And one for the snapshot_id:

- platform: mqtt
  name: Netatmo webhook
  state_topic: 'netatmo/update'
  value_template: '{{ value_json.snapshot_id  }}'
  json_attributes_topic: 'netatmo/update'

And as last a binary movement sensor:

  - platform: template
    sensors:
      netatmo_webhook_trigger:
        device_class: motion
        friendly_name: Netatmo webhook trigger
        value_template: "{{ is_state('sensor.netatmo_webhook_trigger', 'NOC-human') }}"
1 Like

Following the documentation page I didn’t fill the redirect nor the webhook urls… The webhook ban status still says it’s not banned.
I’m unclear with your last answer (excuse my ignorance), do you actually use “{webhook_id}” in your setup page and automation.yaml, or do you replace it with something of your choosing?
Thanks for your help!

Some info https://www.home-assistant.io/docs/automation/trigger/#webhook-trigger

I replace it by something else .

Thanks ! Just tried it out using curl and the HA part works and triggers the automation! I just have to wait for something to pass in front of the camera to see whether that part works as well.

I’m also using this template_sensor

  - platform: template
    sensors:
      netatmo_type:
        friendly_name: Netatmo webhook
        value_template: >-
              {%- if is_state_attr("sensor.netatmo_webhook", "push_type", "NOC-animal") %}
                  Dier
              {%- elif is_state_attr("sensor.netatmo_webhook", "push_type", "NOC-human") %}
                  Persoon
              {%- elif is_state_attr("sensor.netatmo_webhook", "push_type", "NOC-movement") %}
                  Beweging
              {%- elif is_state_attr("sensor.netatmo_webhook", "push_type", "NOC-vehicle") %}
                  Voertuig
              {%- elif is_state_attr("sensor.netatmo_webhook", "push_type", "topology_changed") %}
                  Info
              {%- elif is_state_attr("sensor.netatmo_webhook", "push_type", "NOC-light_mode") %}
                  Licht
              {% endif %}
        icon_template: >-
              {%- if is_state_attr("sensor.netatmo_webhook", "push_type", "NOC-animal") %}
                  mdi:dog-side
              {%- elif is_state_attr("sensor.netatmo_webhook", "push_type", "NOC-human") %}
                  mdi:human
              {%- elif is_state_attr("sensor.netatmo_webhook", "push_type", "NOC-movement") %}
                  mdi:weather-windy
              {%- elif is_state_attr("sensor.netatmo_webhook", "push_type", "NOC-vehicle") %}
                  mdi:car-hatchback
              {%- elif is_state_attr("sensor.netatmo_webhook", "push_type", "topology_changed") %}
                  mdi:information-variant
              {%- elif is_state_attr("sensor.netatmo_webhook", "push_type", "NOC-light_mode") %}
                  mdi:lightbulb-on
              {% endif %}
1 Like

Cheers for the sharing! really appreciate it!

Still nothing… Here is my setup in netatmo connect:

As you can see, there is nothing in the webhook logs despite receiving numerous notifications on event from either the Presence or the Welcome. Have I missed something in the conf ? Should I fill the redirect url as well?

Webhook logs are broken on Netatmo’s side. https://forum.netatmo.com/viewtopic.php?f=5&t=16932

Have you made this automation?

  alias: Netatmo Webhook
  initial_state: 'on'
  trigger:
    platform: webhook
    webhook_id: {webhook_id}
  action:
    - service: mqtt.publish
      data_template:
        topic: 'netatmo/update'
        retain: true
        payload_template: >
           {{ trigger.json | tojson }}

I use MQTT Explorer to look what 's in the message

{"camera_id": "xxxxxxxxxxxxxx", "device_id": "xxxxxxxxxxxxxx", "event_id": "5d4exxxxxxxxxxxxxx5d2380", "event_type": "animal", "home_id": "58330xxxxxxxxxxxxxx4cfd", "home_name": "Nummer 79", "message": "Nummer 79: Dier gezien", "push_type": "NOC-animal", "snapshot_id": "5d4xxxxxxxxxxxxxx381", "snapshot_key": "fe5b542xxxxxxxxxxxxxx680054b51f6acxxxxxxxxxxxxxxbe238eb", "snapshot_url": "https://netatmocameraimage.blob.core.windows.net/production/5d4xxxxxxxxxxxxxx98025dxxxxxxxxxxxxxxe680xxxxxxxxxxxxxx071402be238eb", "subevent_id": "05a8xxxxxxxxxxxxxx60-1f5xxxxxxxxxxxxxx", "user_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx", "vignette_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx", "vignette_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx055301xxxxxxxxxxxxxx5564e8945b", "vignette_url": "https://netatmocameraimage.blob.core.windows.net/production/5xxxxxxxxxxxxxxd23xxxxxxxxxxxxxx261cxxxxxxxxxxxxxx180991xxxxxxxxxxxxxxe8945b"}

Some other people also have problems with webhooks https://forum.netatmo.com/viewtopic.php?f=5&t=16993

My automation looks like this:

- id: Movement Detected
  alias: Netatmo Webhook
  initial_state: 'on'
  trigger:
    platform: webhook
    webhook_id: netatmo_webhook
  action:
  - service: notify.google_push_pixel_2
    data_template:
      message: mouvement détecté
  - service: mqtt.publish
    data_template:
      topic: 'netatmo/update'
      retain: true
      payload_template: >
        {{ trigger.json | tojson }}

and gets triggered if I curl the webhook… I guess the problem is on Netatmo’s side then…

I used a workaround, with IFTTT triggering the webhook when netatmo’s camera detects a movement and although it’s not very reactive, it gets the job done. So I think this confirms that the problem is on Netatmo’s side…

Strange behavior: I created a new Netatmo account with another email, authorized access to my cameras, created an app with this new account, used the new keys and secret in HA, restarted HA, then went back to the old account with the old email. I’m now receiving the webhooks from that new account even though I’m not using the key and secret from that app anymore…
I’m happy cause I finally receive those hooks, but I find this strange.

I build a bit further on this example, wanted to have the Netatmo presence detecton inform HA once I’m home. Using the Netatamo events for this.

Created two template sensors to filter out the Person-IDs, as I noticed sometimes my welcome camara sees two faces at the same time.:

netatmo_person_id0:
friendly_name: 'Netatmo Person'
value_template: '{%- if state_attr("sensor.netatmo_webhook", "persons") != None %}{{state_attr("sensor.netatmo_webhook", "persons")[0]["id"]}}{% endif %}'
netatmo_person_id1:
friendly_name: 'Netatmo Person'
value_template: '{%- if state_attr("sensor.netatmo_webhook", "persons") != None %}{%- if state_attr("sensor.netatmo_webhook", "persons")|length > 1 %}{{state_attr("sensor.netatmo_webhook", "persons")[1]["id"]}}{% endif %}{% endif %}'

Created an automation to inform HA presence that I’m home, based on my unique person ID code from Netatmo.

- alias: Y Occupancy On
  trigger:
  - entity_id: sensor.netatmo_person_id0
    platform: state
    to: 'fe73d1bc-2230-4de7-03a903c8940d'
  - entity_id: sensor.netatmo_person_id1
    platform: state
    to: 'fe73d1bc-2230-4de7-03a903c8940d'
  action:
  - data:
      payload: home
      topic: location/y
    service: mqtt.publish
1 Like

Hey Giel, I tried to use your “binary movement sensor”

but on checking config there’s something invalid:

Invalid config for [sensor.template]: value is not allowed for dictionary value @ data['sensors']['netatmo_webhook_trigger']['device_class']. Got 'motion'. (See ?, line ?).

Are there any changes at device_class in the mean time?