-
Notifications
You must be signed in to change notification settings - Fork 20
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
Switcher power plug with firmware >= 1.46 supports timed base capabilities #335
Comments
I started working on this, first thing I noticed is that Switcher app only let you set the The good thing is that it has no impact on the plan above. as the changes are only made to the paring of incoming status (2. above) and we don't to any changes to the device control (1. above) this will work as planned. The user for the library should not allow setting a timer, although device will only ignore the value and still perform the turn on request. The fact that they are not exactly identical only makes it more clear that we should keep the separation between these two devices. I will edit the comment to indicate the missing timer option. |
Additional information; |
This is very good progress, sorry it took me so long to respond. |
This is the utility function that handles the conversion of the timedelta object to seconds and then to a hex representation. It is invoked by this API function, which is called directly by the customer via the context manager, maybe it will be better to put the enforcement logic here, so we can verify differently per device and call the utility function just for the conversion. Currently, as seen here, the > 24-hour limitation is enforced after the conversion from timedelta to seconds. |
I was scratching my head all night thinking about how can make this work. I see now what you meant by "We will need to discuss how to add this option", this is gonna be a tricky addition to this codebase. |
APIControl deviceWe need to determine whether any modifications are required for the set_auto_shutdown function. Does it work for power plugs like it works for water heaters? Get stateThe get_state function, returns a SwitcherStateResponse, which uses the StateMessageParser for parsing the message. Will the get_auto_shutdown function work? BridgeUpdate device implementationThe SwitcherWaterHeater device class implements:
The SwitcherPowerPlug device class, on the other hand, only implements SwitcherPowerBase and SwitcherBase. This will also mean SwitcherWaterHeater and _SwitcherPowerPlug_are identical; should we merge them? Parse device stateAfter updating the device implementation, the DatagramParser must also be modified. For the SwitcherPowerPlug case, a remaining_time and an auto_shutdown must be passed as well, much like we do for the SwitcherWaterHeater case. Will the get_remaining and get_auto_shutdown work the same for water heaters and power plug? Value overlapAuto shutdownAs noted by @thecode here, there's a different behaviour of the value we get for auto_shutdown from water heaters and power plugs. The water heater limits this value to 24h, while power plugs use 30h to indicate that the configuration is off. We need to explore these contrasts and understand where they meet us. Do we need to take this under consideration in the API's set_auto_shutdown function, the API's state get_auto_shutdown function, the bridge's get_auto_shutdown function, or all of the above? |
So I tested this issue and here is what I learned: Regarding
It seems like no modifications are needed. Regarding
It seems like no modifications are needed. Regarding
Let me know if you want to merge those APIs or not (Will be modified in #833) Regarding
Yes get_remaining and get_auto_shutdown work the same. Regarding
Yes here we have some differences and I fix that by: |
Small update:
Looks like we no longer need this Before the above I got higher than 23 in hours that's why I had to reset (h,m,s) but it seems like it was happening only when the function got called by get_remaining and not by get_auto_shutdown function. |
Did you try to set |
If by 'unlimited' you mean turning off the "auto-shutdown" button then yes. |
I did notice some kind of odd behabvior:
Looks like its coming like this from the packet.. |
We are having a broken discussion, when I set in the past (I don't have a working plug now, will need to find one and check again) "unlimited" time for the plug the value returned by the device was |
I don't know what happened in the past but yes I tested this with my power plug device and its working |
Let's hold with the merge, we can live with two identical classes (SwitcherWaterHeater and SwitcherPowerPlug) for a while, and merge them later on as part of a refactoring effort. |
@YogevBokobza since we started the discussion here I am adding the results here and not on the linked PR. This is with testing with my Switcher Plug:
To debug I added a debug print before
hours: 30, minutes: 0, seconds: 0
My plug is at version 1.46 (which is the most common version from users reports), |
What did you had in mind?
According to research performed by @thecode and @dmatik,
Switcher power plugs
with firmware >= 1.46 supports timed based capabilities such as:These are capabilities that up until now were used in
Switcher water heater devices
.It should be stated, power plugs with firmware < 1.46, return a default value for the remaining time,
So any modification made for this enhancement, should not affect backward compatibility.
Are you trying to fix a problem?
Power plugs with the firmware of >= 1.46 come with the configuration option for auto-shutdown.
This configuration is not visible to this integration.
Any lead on how this feature can be implemented?
We can split this into two workflows:
Setting the device configuration auto-shutdown value
and/or turning it on with a designated timer(timer is not supported see comment,) should probably work out of the box, as the API context doesn't verify the type of the device before sending out the required packet. So I don't think any modifications are required for this part.The device state should display the new capabilities value.
This will require some modifications, so let's dive in:
power_consumption
andelectric_current
properties.remaining_time
andauto_shutdown
properties.SwitcherPowerBase
andSwitcherBase
.SwitcherTimedBased
,SwitcherPoerBase
, andSwitcherBase
._parse_device_from_datagram
in order to return the correct device.Although, as for this enhancement, the power plugs and water heater are basically the same devices.
I wouldn't recommend dropping the separation between them,
we can just add capabilities to the power plug representation and make it similar to the water heater one.
In order to give the power plug timed-based capabilities, we simply need to make the
SwitcherPowerPlug
class inherit fromSwitcherTimedBased
as well as the current inheritance fromSwitcherPowerBase
andSwitcherBase
.Just remember - it's python - order matters so keep it in line with the
SwitcherWaterHeater
class.We then need to add the two new properties when discovering a power plug device,
in
_parse_device_from_datagram
,find the power plug if branch and add the new properties,
it should be quite similar to the water heater if branch.
These modifications are allegedly not that big or complicated,
But I assume testing modification will be required as well.
The text was updated successfully, but these errors were encountered: