I would like to use variable for specified time. Button to change the value and use that in rule. Example: variable $xtime = 7:00. If use “UP” button to 7:15, “DOWN” button 6:45. In rule: if it before $xtime …
-
time variable
-
@envagyok
did you tried a rule to change the xtime value?
if UP is pressed then $xtime = $xtime + 0:15i have no idea if it works. just try it.
-
am not sure if 0:15 can be set without trouble. try with 0.15 or another thing would be - what if it’s 7.45 and your’re pushing the up button? pimatic will then calculate to 7.60 …
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
Coming weekend I want to connect my CV to pimatic to use the thermostat function, but I want to be able to adjust start times per (working) day just like envagyok requests. I normally wake up at 7 but sometimes earlier or later depending on my work. I want a thermostat screen in my pimatic for each weekday being able to do exactly what envagyok wants.
This either requires a plugin (feature request) or calling an external script which pushes back to the api.
W.r.t. the plugin: A (for example) “Monday morning start” up/down button to change the time with steps of 5 minutes (or whatever time slice). This could easily be done in javascript via a plugin (but I did not dive into plugins yet. It could also be an extension on the dummythermostat device as well but that’s also unknown territory for me).
Without a plugin and being a unix adept I will now create a rule to execute a shell or python script with 4 variables: weekday, stop/start (even though I’m currently only interested in start time(=heat up time)), up/down action and time slice (and if no time slice given use 5 minutes as default or so). Split the time string (7:15) on the “:”, calculate the new correct time and push back day and time.
I understand this is not a solution to the initial question but it might give some hints. And if I get something working I will post it.
(And I don’t want to manipulate rules containing those start time variables as I want my wife to be able to do the same from screen without destroying my rules.And she certainly doesn’t want either, just a simple up/down button. She has “resident” authorizations)
-
I am also highly interrested in this feature. In general the feature can be realized with VariablesDevice, ButtonDevice and Rules, but the config gets very lengthy on that. Below a rough experimental snippet (only for Monday) to make clear what I mean. I think it is impractical to use it.
First the variables. Unit is seconds because the Variables Device format this properly in the GUI:
{ "name": "Dev01MoOn", "value": 11100 }, { "name": "Dev01MoOff", "value": 21900 }
Then to display it the VariablesDevice:
{ "id": "Dev01MoDevice", "name": "Dev01 Monday", "class": "VariablesDevice", "variables": [ { "name": "Dev01MoOn", "expression": "$Dev01MoOn", "type": "number", "unit": "s", "label": "Monday On", "discrete": true, "acronym": "On" }, { "name": "Dev01MoOff", "expression": "$Dev01MoOff", "type": "number", "unit": "s", "label": "Monday Off", "discrete": true, "acronym": "Off" } ], "xAttributeOptions": [ { "name": "Dev01MoOn", "displaySparkline": false }, { "name": "Dev01MoOn", "displaySparkline": false }, { "name": "Dev01MoOff", "displaySparkline": false }, { "name": "Dev01MoOff", "displaySparkline": false } ] }
Then you need some Buttons to change the values. I decided to use 4 Buttons for each value, +10min,-15min,+1hour,-1hour only as an example, should be adapted to your needs.
{ "id": "Dev01MondayButtons", "name": "Dev01 Monday Set", "class": "ButtonsDevice", "buttons": [ { "id": "Dev01MoOnDown", "text": "-15" }, { "id": "Dev01MoOnUp", "text": "+10" }, { "id": "Dev01MoOnDownH", "text": "-h" }, { "id": "Dev01MoOnUpH", "text": "+h" }, { "id": "Dev01MoOffDown", "text": "-15" }, { "id": "Dev01MoOffUp", "text": "+10" }, { "id": "Dev01MoOffDownH", "text": "-h" }, { "id": "Dev01MoOffUpH", "text": "+h" } ] }
And finaly the rule for incrementinng and decrementing including range and consitency checking:
{ "id": "dev01-mo-on-up-button-pressed", "name": "Monday on button pressed", "rule": "if Dev01MoOnUp button is pressed and $Dev01MoOn <= 85500 then set $Dev01MoOn to $Dev01MoOn + 900 and $Dev01MoOff = max($Dev01MoOn + 900,$Dev01MoOff)", "active": true, "logging": true }, { "id": "dev01-mo-on-down-button-pressed", "name": "Monday on button pressed", "rule": "if Dev01MoOnDown button is pressed and $Dev01MoOn >= 600 then set $Dev01MoOn to $Dev01MoOn - 600", "active": true, "logging": true }, { "id": "dev01-mo-on-up-button-pressed-2", "name": "Monday on button pressed 2", "rule": "if Dev01MoOnUpH button is pressed and $Dev01MoOn <= 82800 then set $Dev01MoOn to $Dev01MoOn + 3600 and $Dev01MoOff = max($Dev01MoOn + 3600,$Dev01MoOff)", "active": true, "logging": true }, { "id": "dev01-mo-on-down-button-pressed-2", "name": "Monday on button pressed 2", "rule": "if Dev01MoOnDownH button is pressed and $Dev01MoOn >= 3600 then set $Dev01MoOn to $Dev01MoOn - 3600", "active": true, "logging": true }, { "id": "dev01-mo-off-up-button-pressed", "name": "Monday off up button pressed", "rule": "if Dev01MoOffUp button is pressed and $Dev01MoOff <= 85500 then set $Dev01MoOff to $Dev01MoOff + 900", "active": true, "logging": true }, { "id": "dev01-mo-off-down-button-pressed", "name": "Monday off down button pressed", "rule": "if Dev01MoOffDown button is pressed and $Dev01MoOff >= 600 then set $Dev01MoOff to $Dev01MoOff - 600 and $Dev01MoOn = min($Dev01MoOff - 600,$Dev01MoOn)", "active": true, "logging": true }, { "id": "dev01-mo-off-up-button-pressed-2", "name": "Monday off up button pressed 2", "rule": "if Dev01MoOffUpH button is pressed and $Dev01MoOff <= 82800 then set $Dev01MoOff to $Dev01MoOff + 3600", "active": true, "logging": true }, { "id": "dev01-mo-off-down-button-pressed-2", "name": "Monday off down button pressed 2", "rule": "if Dev01MoOffDownH button is pressed and $Dev01MoOff >= 3600 then set $Dev01MoOff to $Dev01MoOff - 3600 and $Dev01MoOn = min($Dev01MoOff - 3600,$Dev01MoOn)", "active": true, "logging": true }
That’s only for Monday.
Hope it is clear, that we need some external script or plugin for this instead. Would be nice if it is generic in some way. In my case I have a heating system with four timers per day for 2 pipes I would like to show on the GUI and change on demand.
-
@Heizelmann
thank you for figuring out.
in my opinion its to complex and should realised in an separate pluginedit: or instead of a plugin it should implemented in pimatic directly
-
@dk00000 That is what I would like to express.
-
@dk00000 said:
in my opinion its to complex and should realised in an separate plugin
edit: or instead of a plugin it should implemented in pimatic directly
sounds like a job for @sweetpi or @mwittig or another @Developer who’s darning to do
a time device that outputs its processings into a variable would be a nice feature.let’s upvote this feature request at the first post above
pimatic v0.9 has been released!
Support Pimatic and get some free stickers
Like us on Facebookmake it so !
-
The example “instruction set” for Monday created by @Heizelmann (thanks for the example) doesn’t need to really be per day, meaning 5 sets. If the schedule changes almost daily and the next week(s) again, you only need a “working_day” “instruction set” with an additional default rule, default variable and default start time (no matter whether it is (central) heating, lights or whatever combination which changes daily).
So "if it is [monday or tuesday or …] and it is after $start_time …"
or more intelligent “if it is not [saturday or sunday] …”Default time (variable) is for example 06:30 and you need Monday earlier, Tuesday default, Wednesday later and Thursday and Friday default.
You simply set it earlier on Sunday for the Monday,
you press the default button on Monday for Tuesday,
On Tuesday you set it later for Wednesday,
etc. etc.I’m still strongly in favor for a plugin but an “instruction” set per “working_day” with that default start time/button/rule would at least simplify it to one instruction set instead of 5 instruction sets. It is a work around I can use as long as we don’t have a plugin (and I assume it will get there
)
-
Hi guys. Here is my temporary solution with bash script.
#!/bin/bash
URL="http://localhost/api/variables"
USERNAME="username"
PASSWORD=“password”VNAME=$1
REQMINUTE=$2CTIME=$(curl -X GET --user “$USERNAME:$PASSWORD” -s $URL/$VNAME | grep value": | awk -F" ‘{print $4}’)
if [ “$REQMINUTE” -lt “0” ]
then
REQMINUTE=$((1440+$REQMINUTE))
fiRTIME=$(date -d “$CTIME $REQMINUTE minutes” +’%H:%M’)
curl -s -X PATCH --header “Content-Type:application/json” --data ‘{“type”: “value”, “valueOrExpression”: "’$RTIME’"}’ --user “$USERNAME:$PASSWORD” $URL/$VNAME > /dev/null
first parameter: the variable name
second parameter: number of minutes (+ or -)*rule example:
"if button is pressed then execute “/home/pi/vartime.sh timer1 15"”
"if button is pressed then execute “/home/pi/vartime.sh timer1 -15"” -
Thanks. Very nice solution.