-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
Miflora #3053
Miflora #3053
Conversation
Get name from sensor, if not defined
return self._unit | ||
|
||
@property | ||
def force_update(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.
- D400: First line should end with a period (not 'e')
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 has been fixed, but it seems that this comment isn't updated automatically.
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.
Farcy comments on the method definition - your code change is the line below - it's a terrible little bot, has bunch of bugs. Don't worry about it :-)
|
||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ | ||
vol.Required(CONF_MAC): cv.string, | ||
vol.Required(CONF_MONITORED_CONDITIONS, 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.
'default' is unnecessary when the option is required.
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
self.data.append(data) | ||
else: | ||
LOGGER.debug("Did not receive any data for %s", self.name) | ||
|
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.
Should there be a 'return' here?
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's not necessary as update won't change anything in this case. But I can add a return, it doesn't hurt.
Would it be possible to support several sensors? |
Yes, you can just define multiple sensors in the configuration. Every sensor has a different MAC address. |
Have you tested with multiple sensors? |
No, I only have a single sensor here (waiting for more to be delivered), but I don't see any reason why it shouldn't work with multiple sensors. |
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=900) | ||
CONF_MAC = "mac" | ||
CONF_FORCE_UPDATE = 'force_update' | ||
DEFAULT_NAME = "" |
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.
How about DEFAULT_NAME = "Mi Flora"
?
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.
If no default is given, the name is retrieved from the device itself. Personally, I like this more than a hard-coded default name.
However, if you're have more than a single plant and your using more than a single sensor, you will usually configure a new for each of them anyway.
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.
So, DEFAULT_NAME
would not be needed at all and instead doing the test for an empty string it could be done against None
.
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.
That's right. I will change this.
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.
I was thinking about this again. Reading the name from the sensor during initialization isn't a good idea when the sensors temporary isn't available. Therefore I have changed the code name to use a hard-coded default name. (The name in the sensor is usually also always the same, therefore it doesn't help to differentiate between sensors).
|
||
LOGGER = logging.getLogger(__name__) | ||
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=900) | ||
CONF_MAC = "mac" |
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.
Mixing '
and "
You will need to add unit test or add the files to |
Unrelated - I wish I knew about these a few months ago when I started my indoor garden. Maybe next go round :-) |
Units tests can't be implemented here as this would not only require a Linux system with a Bluetooth stack but also a working sensor. Both isn't available on the test system. |
Then you need to add the files to .coveragerc On Aug 30, 2016 10:38 PM, "Open Home Automation" notifications@github.com
|
The sensor file is already added to .coveragerc |
Fuck I'm tired - totally missed it. On Tue, Aug 30, 2016 at 10:49 PM, Open Home Automation <
|
So the only real issue is the mixing of quotes. |
- set state to None if no data could be polled from sensor
more logging
@property | ||
def unit_of_measurement(self): | ||
"""Return the units of measurement.""" | ||
return self._unit |
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.
If the HASS configured unit system is imperial , we should be doing a conversion from C to F (both unit of measurement and state properties)
Is this ready to merge now? |
@Danielhiversen From my point of view it is ready to merge. |
Looks good! 🐬 |
* First version of the MiFlora sensor (not yet finished) * First workign version * Added some documentation Get name from sensor, if not defined * Ignore IOError * Added force_update option * Updated comments * Renamed fertility to conductivity (what it really is) * MiFlora library update * Updated helper files * Formatting * Fixed pylint errors * Removed default from monitored conditions * Removed KeyError handling as a KeyError should never be raised * Added a return when no data is received * emoved unnecessary return statement * Changed default name * Changes quotes and string operation ( @Teagan42 ) * - number of samples for median calculation is now configurable - set state to None if no data could be polled from sensor * Bugfix in library more logging * Fixed miflora version number
@open-homeautomation could you add the website docs for this, please? |
Yes, I will work on this. |
Description: Support for Mi Flora plant sensor
Related issue (if applicable): fixes #
Pull request in home-assistant.io with documentation (if applicable): not yet done
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][ex-requir]).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.