Input box for variable

Moderator: leecollings

Post Reply
JuanUil
Posts: 500
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11083
Location: Asten NB Nederland
Contact:

Input box for variable

Post by JuanUil »

Hi there Domoticz friends,

Since we are away a lot of weekends to the Belgian coast I have made some code to heat up my house gradually before we travel home again.
Idea is that I switch a dummy to start up the code.
What I would like to have is a pop up input box where I can give the starting and end time.
Is this possible?
The code:

Code: Select all

setpoint = tonumber(otherdevices_svalues['Room Setpoint'])
werkelijk= tonumber(otherdevices_svalues['Room Temperature'])
uur = tonumber(os.date("%H"));
minuten = tonumber(os.date("%M"));
seconden = tonumber(os.date("%S"));
dagtemp   = uservariables["dagtemperatuur"]

commandArray = {}

for i=9,20,1 do 
    if (uur== i and minuten==5 and seconden==0 and setpoint<=dagtemp) then
        print ("sec=  "..seconden.." i= "..i)
        setpoint=setpoint+0.5
		set = "6|0|" .. setpoint
		commandArray ['UpdateDevice']= '6|0|' .. setpoint  
    end
end

return commandArray
Thnx for any advice.
Jan
Your mind is like a parachute,
It only works when it is opened!

RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
JuanUil
Posts: 500
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11083
Location: Asten NB Nederland
Contact:

Re: Input box for variable

Post by JuanUil »

anybody any idea?
Your mind is like a parachute,
It only works when it is opened!

RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Input box for variable

Post by Nautilus »

I'm using a script to make sure the car has heated for a proper time (based on outside temperature) before leaving the house. The next departure time is stored as a user variable. For Android there is an app with which you can update domoticz user variables, but for iOS there currently isn't any. So I made a simple .php page with input form (containing a time picker drop-down list) and a submit button that will then trigger the json to update the user variable value. I think something like this is the closest you can get - at least easily. You can have this page available under the "Custom" tab in Domoticz if you store the page under ../domoticz/www/templates
JuanUil
Posts: 500
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11083
Location: Asten NB Nederland
Contact:

Re: Input box for variable

Post by JuanUil »

Hi Nautilus,
tnx for your reply. could you post me your solution because it looks good but i am not skilled in php programming.
thank you in advance.

Jan
Your mind is like a parachute,
It only works when it is opened!

RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Input box for variable

Post by Nautilus »

Well, I think there no use in copying mine but something like this could get you started:

Add form with input box and submit button:

Code: Select all

<!DOCTYPE html>
<html>
<form name="single2" method="POST" action="">
	<input type="text" value="" id="timer2" name="timer2" />
	<input type="submit" name="submit2" value="Submit">
</form>
</html>
React to pressing the submit button ( = update uservariable):

Code: Select all

<?php
if(isset($_POST['submit2'])){
	$timer2 = urlencode($_POST['timer2']);}
	file_get_contents('http://domoticzurl:port/json.htm?type=command&param=updateuservariable&vname=VARIABLENAME&vtype=2&vvalue='.$timer2);	
}
?>
Then it is up to you what else and what kind of formatting you want to have there...:)
JuanUil
Posts: 500
Joined: Friday 22 May 2015 12:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.11083
Location: Asten NB Nederland
Contact:

Re: Input box for variable

Post by JuanUil »

Thank you, I will work on it this weekend. For a start it is oké!
Your mind is like a parachute,
It only works when it is opened!

RPI4 several Fibaro, KaKu, Neocoolcam switches, Z-Wave, Zigbee2Mqtt, Ikea bulbs and remote, Zigbee temp nodes
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest