-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Netatmo binary sensor #3455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Netatmo binary sensor #3455
Conversation
5a2e300
to
a378793
Compare
return self._name | ||
|
||
@property | ||
def unique_id(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove that. The HA core do that same and is more robust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, if a platform implements it it will be better. They know exactly which is unique. However, a name is not very unique? Do you have access to a serial?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the netatmo api provides an unique ID for each camera/device
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change Done
return self._name | ||
|
||
@property | ||
def unique_id(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, if a platform implements it it will be better. They know exactly which is unique. However, a name is not very unique? Do you have access to a serial?
@@ -50,7 +49,4 @@ def setup(hass, config): | |||
_LOGGER.error("Unable to connect to NatAtmo API") | |||
return False | |||
|
|||
for component in 'camera', 'sensor': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove discovery ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was creating issue as some person can have the weather station but does not have the camera, or they could have multiple camera and displaying only one.
My original goal was to use the discovery if no camera was settup but if one was setup, then do not use the discovery, but currently it did not work well as two feed of the same camera could be displayed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other platforms fix this by checking the data to see if there is a camera, sensor etc.
I want to keep the discovery in because it is helps users get started. If the camera component will only setup 1 camera, then that is also that has to be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No the camera component can setup as many camera as you want, but the thing is that might don't want to have all the information from the camera, for instance, the binary sensor create 3 sensor by camera by default, bu user might don't want to have the 'Someone known' sensor if they have a more precise device tracker (moreover with my next update which should implement presence detection based on the Netatmo camera).
I would me more than happy to use the discovery, but discovery use the default config (all camera, all sensors) but if I setup a specific config it creates duplicate in the interface (the feed from discovery and the one from specific setup)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it configurable but default it to on
as automatic setup of platforms helps new users get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok do you have example that I can copy
return None | ||
|
||
|
||
class WelcomeData(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a direct copy of the one in camera
? Why not make it a generic object, instantiated once in the main component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You 're right and as this code will also be use for the coming presence detection platform, it make more sense to put inside components/netatmo.py
a378793
to
220ceab
Compare
You can use two aproches in order to use discovery:
The last one could be done in the netdisco ant it would emit in your case only two entities discovered and then in HA two different components would listen for them and render them in the frontend |
@rofrantz I used the second approach but it was not perfect as the Netatmo API will return all the devices that you own, but if you have one camera in one home and an another one in another home you might don't want to display both in you home-assistant interface. My idea was to use the discovery if no specific camera has been setup in the configuration.yaml (then it will use the default camera), but if a camera is setup then discovery is ignored. |
Still sounds like a custom setup meaning that u have 2 cameras in 2 different locations in the same HA instance; why dont u hide one of two entities if thats the issue or add a default camera flag. |
@@ -50,7 +49,7 @@ | |||
} | |||
|
|||
MODULE_SCHEMA = vol.Schema({ | |||
vol.Required(CONF_MODULE_NAME, default=[]): | |||
vol.Required(cv.string, default=[]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix for #3287
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this fix was bundled with a PR for a feature, I have missed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I'm preparing another PR for this fix solely
715d7d7
to
cd354a7
Compare
if config[CONF_CAMERAS] != []: | ||
if camera_name not in config[CONF_CAMERAS]: | ||
continue | ||
if CONF_CAMERAS in config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you simplify this by moving it outside of the loop (it won't change during the loop) and also convert to be 1 if statement.
@@ -50,7 +49,4 @@ def setup(hass, config): | |||
_LOGGER.error("Unable to connect to NatAtmo API") | |||
return False | |||
|
|||
for component in 'camera', 'sensor': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it configurable but default it to on
as automatic setup of platforms helps new users get started.
sensors = config.get(CONF_MONITORED_CONDITIONS, SENSOR_TYPES) | ||
|
||
for camera_name in data.get_camera_names(): | ||
if config[CONF_CAMERAS] != []: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you simplify this by moving it outside of the loop (it won't change during the loop) and also convert to be 1 if statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is difficult to simplify as this solution allows me to have only one for loop instead of two
Signed-off-by: Hugo D. (jabesq) <jabesq@gmail.com>
Signed-off-by: Hugo D. (jabesq) <jabesq@gmail.com>
Signed-off-by: Hugo D. (jabesq) <jabesq@gmail.com>
And global config to disable discovery for netatmo devices Signed-off-by: Hugo D. (jabesq) <jabesq@gmail.com>
cd354a7
to
8c602f3
Compare
🐬 |
Description:
This PR create a new platform which provides binary sensor based on event seen by the Netatmo camera
Related issue (if applicable): fixes #
Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#964
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If code communicates with devices, web services, or a:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.