plasticrake / homebridge-tplink-smarthome

TP-Link Smarthome Plugin for Homebridge
MIT License
467 stars 70 forks source link

HS110: Motion sensor for energy consumption #317

Open awaescher opened 8 months ago

awaescher commented 8 months ago

Current Situation

I have few HS110 and they work perfectly with this plugin, thank you so much for building and maintaining it!

The HS110 can monitor their current energy consumption. It would be so awesome to define a threshold like 100 watts from when the plugin triggers a motion sensor.

This might be the easiest way to implement automations for complement devices to running devices like turning lights off, when the TV starts or getting a push notification as when the wash machine does not consume energy anymore.

Proposed Change

In HomeBridge, I would love to have the possibility to define a threshold for each HS110 separately which can be considered off or on. As soon as the energy consumtion is over the threshold, the motion sensor should fire and stay on until the energy consumption is lower than the threshold.

Timely conditions

I can think of a situation where the energy consumption might get over or under the threshold for a short amount of time so it would be amazing to have some kind of time check too.

I know this is getting more complex with it but something like: "On if the energy consumption is over {threshold} for {timespan} without being interruped (under the threshold)" and "Off if the energy consumption is under {threshold} for {timespan} without being interrupted (over the threshold)".

Like:

TV on/off
threshold: 100 watts
for at least: 20 seconds

Right now I am doing this with a ping check btw whether the TV is responsing or not but this is not as reliable as it should be.

Special case: Laundry

This is to smooth out measurement errors or small dips/peaks in general but could also eliminate a common problem with recognizing wash machine or dryer states which is that they turn off for a few mintues just to continue afterwards frequently. Most energy based checks fire like 5-10 false "wash maschine is done" notifications. With the approach above, this could be done like:

washing machine on/off
threshold: 200 watts
for at least: 15 minutes

So if the machine stays under 200 watts for at least 15 minutes, a push notification could be triggered. Note that this would also take 15 minutes to recognize that the machine is running but I think this would be okay for most automations that require such a long timespan.

Separate time spans for on/off

To eliminate the long waiting time for the wash machine to be recognized as "running", it would be also possible to define two different time spans: One for turning the sensor "on" and one for "off".

washing machine on/off
threshold: 200 watts
on when over for at least: 1 minute
off when under for at least: 15 minutes

I think this way it would be possible to cover most devices with corresponding automations but it might be a bit of an overkill 😬