-
Notifications
You must be signed in to change notification settings - Fork 62
Added settings for Meter Pro Co2 #430
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
base: master
Are you sure you want to change the base?
Conversation
|
This may solve #416. |
|
Additional unit tests are needed. It is recommended to create a base class |
|
@elgris @zerzhang I integrated my code into the new structure, removed my own time-implementation and started implementing unit-tests (more are coming when i have more time).
I have no way to verify which methods would actually work on a MeterPro, so i am not sure abbout that. |
switchbot/devices/meter_pro.py
Outdated
|
|
||
| COMMAND_TEMPERATURE_UPDATE_INTERVAL = f"{SETTINGS_HEADER}070105" | ||
| COMMAND_CO2_UPDATE_INTERVAL = f"{SETTINGS_HEADER}0b06" | ||
| COMMAND_FORCE_NEW_CO2_Measurement = f"{SETTINGS_HEADER}0b04" |
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.
(style) it should be all uppercase COMMAND_FORCE_NEW_CO2_MEASUREMENT.
switchbot/devices/meter_pro.py
Outdated
| + absolute_humidity_low_bytes | ||
| ) | ||
|
|
||
| async def set_alert_co2(self, on: bool, co2_low: int, co2_high: max, reverse: bool): |
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.
Typo: co2_high: int,
| """ | ||
| Sets the CO2-Alert. | ||
| on: Turn CO2-Alert on or off | ||
| lower and upper: The provided range (between 400ppm and 2000ppm in 100ppm steps) |
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.
between 400ppm and 2000ppm in 100ppm steps: worth validating this values in the code?
|
|
||
| mode = 0x00 if not on else (0x04 if reverse else 0x03) | ||
| await self._send_command( | ||
| COMMAND_ALERT_CO2 + f"{mode:02x}" + f"{co2_high:04x}" + f"{co2_low:04x}" |
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.
Do we need to send these limits if on is False? I haven't tried this with the device, but I'd assume that it expects all zeroes. If so, then we can probably make set default values for co2_high and co2_low args to 0 and drop their validation when on is False.
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, this would be a reasonable design, but is not what the original app does.
The test I pushed for this method contains only payloads from the original App.
When a mode gets turned off, all values remain set as they were before. And all of them get transmitted.
I tried to stick as close to this as possible. I did not test how the device would react to your proposal.
| Sets the interval in which temperature and humidity are measured in battery powered mode. | ||
| Original App assumes minutes in {5, 10, 30} | ||
| """ | ||
| seconds = minutes * 60 |
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.
switchbot/devices/meter_pro.py
Outdated
|
|
||
| async def set_button_function(self, change_unit: bool, change_data_source: bool): | ||
| """ | ||
| Sets the function of te top button: |
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.
Typo: te -> the
|
I'd also suggest checking |
|
I added more tests and fixed the typos you found. |
I reverse-engineered the settings of the Meter Pro (CO2) and implemented them here.
I have no means of testing if this work for the other Meter models.
An example script to fully configure a device using this would be for example
Additionally one can trigger a new measurement regardless of the frequency using
await meter.force_new_CO2_measurement()and calibrate the sensor (at fresh air!) usingawait meter.calibrate_co2_sensor().