Skip to content

Switcher power plug with firmware >= 1.46 supports timed base capabilities #335

@TomerFi

Description

@TomerFi

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:

  • Auto shutdown of the device based on the configured value.
  • Displaying the remaining time for the current run.

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:

  1. 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.

  2. The device state should display the new capabilities value.
    This will require some modifications, so let's dive in:

  • The DeviceCategory Enum is used to categorized the device type.
  • The DeviceType Enum helps us identify the discovered device.
  • The DeviceState Enum although, not quite related to this issue, but worth mentioning, helps us categorized the device's state.

  • The SwitcherBase class is the abstraction all switcher devices inherit from.
  • The SwitcherPowerBase class is an abstraction used for switcher devices with the capability to have power_consumption and electric_current properties.
  • The SwitcherTimedBase class is an abstraction used for switcher devices with the capability to have remaining_time and auto_shutdown properties.

  • The SwitcherPowerPlug class is a concrete implementation of the switcher power plug, it inherits from both SwitcherPowerBase and SwitcherBase.
  • The SwitcherWaterHeater class is a concrete implementation of the switcher water heater, it inherits from SwitcherTimedBased, SwitcherPoerBase, and SwitcherBase.

  • The _parse_device_from_datagram private method is the one place that identifies the different device types.
  • The SwitcherBridge is the udp context manager that utilizes the above _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 from SwitcherTimedBased as well as the current inheritance from SwitcherPowerBase and SwitcherBase.
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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions