core icon indicating copy to clipboard operation
core copied to clipboard

Add binary sensors for netatmo NIS and NACamDoorTag devices

Open yannc74 opened this issue 1 year ago • 9 comments

Proposed change

Add binary sensors for NIS and NACamDoorTag devices, Device NIS: reachable monitoring: On/Off sound: True if the siren souding (alert) (webhook with the event home_alarm)

Device NACamDoorTag: reachable opening : True if the window/door is open or webhook tag_open is received motion: True if webhook tag_big_move is received vibration: True if webhook tag_small_move is received

After, I'll update sensors.py for these devices, if you are ok with these updates First commit: binary sensors Second commit: sensors

I have done this update for my heating

Type of change

  • [ ] Dependency upgrade
  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [ ] New integration (thank you!)
  • [x ] New feature (which adds functionality to an existing integration)
  • [ ] Deprecation (breaking change to happen in the future)
  • [ ] Breaking change (fix/feature causing existing functionality to break)
  • [ x] Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • [ x] The code change is tested and works locally.
  • [ x] Local tests pass. Your PR cannot be merged unless tests pass
  • [ x] There is no commented out code in this PR.
  • [ x] I have followed the development checklist
  • [ x] I have followed the perfect PR recommendations
  • [ x] The code has been formatted using Ruff (ruff format homeassistant tests)
  • [ x] Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • [ ] The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • [ ] New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • [ ] For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

yannc74 avatar Jul 06 '24 20:07 yannc74

Hey there @cgtobi, mind taking a look at this pull request as it has been labeled with an integration (netatmo) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of netatmo can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign netatmo Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

home-assistant[bot] avatar Jul 06 '24 20:07 home-assistant[bot]

Nuts !!!! Will make happy tons of netatmo users !

juliengdt avatar Aug 23 '24 21:08 juliengdt

💯 I've been using this change proposal in a custom component for a few weeks now, it works fine ! Thanks

adriencog avatar Aug 31 '24 12:08 adriencog

To me those are not sensors in a state kind of way since they represent events. That is the only issue that I have with this.

cgtobi avatar Aug 31 '24 16:08 cgtobi

Hello,

my first goal is to have the status for a window, because I'm using this state for my heating. So, it's required to have the status givent by the API homestatus and updated by the events.

I use a custom component with theses sensors and some binary sensors (DOORTAG: => OPENING, MOTION, VIBRATION, SIREN => SAFETY, SOUND) (these sensors are not yet delivered).

I can update and push the binary sensors.

So, how can we advanced on this topic ? Have you an another way to implement this goal ?

Thanks

yannc74 avatar Sep 02 '24 09:09 yannc74

Again, in my opinion those are momentary events and not states that persist. That is the reason that they were removed quite a while ago. What qualifies this as sensors to you?

cgtobi avatar Sep 03 '24 06:09 cgtobi

Hello,

the call /homestatus on the Netatmo's API return for:

NIS:

  • reachable:true
  • status:"no_sound" (enum values: "now_news", "no_sound", "warning", "sound", "playing_record_0", "playing_record_1", "playing_record_2", "playing_record_3")
  • monitoring:"off"

NACamDoorTag:

  • reachable:true
  • status:"open" (enum : "no_news", "calibrating", "undefined", "closed", "open", "calibration_failed", "maintenance", "weak_signal")

So, I thinks these attributes can be seen as diagnostic sensors.

So, theses states are given by homestatus and by some events:

  1. tag_open, tag_big_move and tag_small_move for NACamDoorTag
  2. home_alarm when the state of the siren change (on/off) in the app "Netatmo Security". Require a force_update in the Netamo component.

After, about the binary sensors. Depend the reachbility, we can compute a state for the opening, motion and vibration sensors. And these sensors can be used for alerts and heating products (aka Versatile Thermostat and opened/closed windows)

But, If I follow yours ideas, I'm ok with the fact that the motion and vibration are not sensors. But, for the others (OPENING (=NACamDoorTag.status) , SAFETY (NIS.monitoring) and SOUND (NIS.status), they can be used as binary sensors.

And If i remember, (I can check later), when the camera is deactivated, the webhooks does'nt work. The only way to update a windows's state is the call homestatus.

yannc74 avatar Sep 03 '24 13:09 yannc74

Hello, so, I confirm when the camera is off, the webhook are not received. So, the status for a Door Tag can be updated by the call 'api/homestatus'

Now, I confirm that these status must be sensors.

It's does'nt work only by webhook.

Thanks for your responses.

yannc74 avatar Sep 10 '24 07:09 yannc74

This would be so awesome to have :) Thanks for the work.

ajsicek avatar Oct 15 '24 02:10 ajsicek

I've marked this PR, as changes are requested that need to be processed. Please un-draft it once it is ready for review again by clicking the "Ready for review" button.

Thanks! 👍

../Frenck

Learn more about our pull request process.

frenck avatar Nov 08 '24 20:11 frenck

I still don’t agree that binary sensors are the right way. Please consider implementing event entities instead.

cgtobi avatar Nov 10 '24 20:11 cgtobi