SonOff POW > Play Station > 120 mins


(denis) #1

Hi there all,
I want to make a rule for my son in order to let him to play with the Play Station for 2 hours.

I allready have the SonOff POW working and give me the watt number when power on whit this string in sitemap:
Text item=SonOff1Power label=“Power [%.1f Watt]” icon=“switch”

I must make e rule like:

if SonOff1Power > 10watt then add 1 every minute to the variableTotalMinutes.
When variableTotalMinutes > 120 minutes then send OFF command to the SonoffPOW item.

Can anybody please help me to make this rule please ?

Thanks in advance
Denis


(lipp_markus) #2

I cannot give you the solution but similar requests have been made and answered repeatedly under the keyword ‘counter’, e.g., here: Generator hours counter
Maybe you can glean enough from this (and other posts regarding counters) to help you in your rule.


(denis) #3

Thanks a lot
I’ll give it a look :slight_smile:
Denis


(Sergey M) #4

Just my opinion …
I would not severely shut down a working computer. IMHO solution you need to look for software on the computer itself.


(denis) #5

Wel …if I tell him to finish to play on Play Station, then he tell me that just stay in order to save the game
…and after I forget, he remain for another hour or much more.

With this project will bi controlled and the Play Station will be turned off.
I don’t think that the PS will broke if I take out the current.

I don’t understand how much times the “rule” routunes will be called during the day.
I mean… if I make a routine in the rule file, every how much time will be called ?

Thanks all
Denis


(Thomas Binder) #6

To measure the time, the PS is powered on, you would:

  1. create the rules as mentioned above
  2. make a second rule every night at midnight, which resets the Counter

you should read the guide for rules
http://docs.openhab.org/configuration/rules-dsl.html

Rules are either “item”-triggered, meaning some item is changed or they are time-triggered (cronjob-syntax). There can also be triggered on system-status or changing of Things.
In your case, the first rule would be item-triggered (power consumption) and the second one would be time-triggered (midnight).

If you have your TV on a Switch-item, I would just make sure, the TV cant’t get power again, if the counter reached the Maximum time. So your son would not loose his game. :wink:


(denis) #7

Thanks a lot Thomas,
I think I’ll make all of rule as cron based.

Something like:
-every 1 min check the SonOffPow
if > 10 Watts add 1min to a variable
-when variable > 120 Watt > send power OFF to SonOff

Then another rule:
-every 6:00 AM 1 send power ON to SonOff
and set variable at 0 min.

I can’t stop the TV cause he use it more time that the PS.
So I must hard power off the Play Station.

But I’m near to buy the google home mini and maybe
I will can send message like “Attention… 10 min remain for Play Station” :slight_smile:

Thanks a lot again
Denis


( ) #8

You should add another rule:

-every 1 min check the SonOffPow
if Sonoff is not online add 2min to a variable

That might be a way to teach him not to try to trick your setup… of course you will need another way of forcing the shutdown then. Btw. Honestly I think your son will quickly find another hack :slight_smile:


(denis) #9

I think is not so good this rule… or maybe I’m not understanding it cause my english :slight_smile:

This because if he play for just 40 min and after he make a pause,
the counter must remain at 40min… in order to add another minutes when my son return to play.

O.T. The simplest way to add a voice that can be controlled by the OpenHab, near the Play Station ?

Thanks all
Denis


( ) #10

“online” means in Wifi and operational. In the position of your son, the first thing I’d do is remove the Sonoff somehow :smile: - but of course if he get’s this far nothing is stopping him from having it still connected but not to the PS. Maybe enhance the rule to be “not online OR online but 0.0 watts power reading” :wink:


(denis) #11

Yes … great idea
Thanks a lot :slight_smile:


(Dexter) #12

how do you managed to connect sonoff POW with openhab? have you flashed the firmware and do some soldering on it?

I’ have one of it, used fora a while with its app but now I would like to deeply integrate it in a new house with openhab and was wondering how to merge the thw systems with mqtt.

thank you


(denis) #13

Search on web, how to flash tasmota firmware on Sonoff.
There is a lot of step-by-step docs.

You’ll must solder something but no complicated.

Take a llok at this video… but make the Tasmota firmware and not that one

Welcome :slight_smile:
Denis


(Thomas Binder) #14

There’s a full-fledged thread here for using the Tasmota-Firmware:

…and regarding the Sonoff PoW, you don’t Need soldering, you can use some Pogo Pins (you know, the cables with the Spikes on the top), just put them in the regarding holes on the platine, works perfectly.