Weekly programming

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.

Moderators: leecollings, remb0

bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Weekly programming

Post by bigpea »

Ok, I think that I'm at good point.. I show the timer table.. but.. I can't update it.
In the detail, if I click on "Update" button, the request respond with a success (I show the notification in the "seccess" statement) but the timer is not updated.

Do you have any idea?

Thanks.

My code:

Code: Select all

$.ajax({
	url: urlcmd,
	async: false,
	dataType: 'json',
	username: $.domoticzUser, 
	password: $.domoticzPassword,
	beforeSend: function(jqXHR, settings) {
		console.log('1. urlcmd: '+settings.url);
	},
	error: function () {
		if ($.enableNoty == true){
			new Noty({
				text: 'Errore durante l\'aggiornamento.',
				type: 'error',
				theme: 'bootstrap-v4',
				timeout: $.timeNoty
			}).show();
		}
	},
	success: function(){
		if ($.enableNoty == true){
			new Noty({
				text: 'Aggiornamento eseguito correttamente.',
				type: 'success',
				theme: 'bootstrap-v4',
				timeout: $.timeNoty
			}).show();
		}
	}
}
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Weekly programming

Post by bigpea »

Only one other info, if I try to execute the command via browser (directly from url) I receive this error:

Code: Select all

var data={
   "status" : "ERR"
}

?(data);
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

Hi bigpea

In the planning.js file, this is the updateSetPoints function which should be called.
If you look at the code, you would see it required :
- the $.devIdx variable which is the device number stored on each page when you edit it.
- defaults.commandClear
- defaults.commandAdd
- ...

How did you initialize PlanningTimerSheet?

Have you tried to debug with the javascript debugger of your web browser(F12 or Ctrl + Shitt + i) and set a breakpoint inside the updateSetPoints function to run step by step and watch variables states?

Regards
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Weekly programming

Post by bigpea »

Il thanks, maybe I found the problem, I’m trying to update a ‘selector’ device with command ‘addSetPointTimer’.
Could you tell me the correct command, maybe the problem is this..
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

Are you talking a selector swtich? In this case, this is not a addSetPointTimer which should be called.
Look at the example for selector : https://gist.github.com/syrhus/8fbb01fb ... be210993c8

scroll down to ShowTimers function:

if( ($.isDimmer || $.isSelector) || !$.bIsLED){
var options = {"insertAfter":$('#lightcontent #timerparamstable').nextAll('a.btnstyle3'),
"commandAdd":"addtimer",
"commandClear":"cleartimers",
"refreshCallback":function(){RefreshTimerTable($.devIdx);},
"temperatureModes":false
};
if(($.isDimmer || $.isSelector))
$.extend(options, {
"modes": $.map( $.selectorSwitchLevels, function(val,i){
if (i === 0)
return null;
return {"value":i*10, "class":"m"+(i-1), "name":val };}),
"propValue":"Level",
"propValueAjax":"level"});
else
$.extend(options, { "modes": [{"value":0,"name":$.t("On"), "class":"green"},{"value":1,"name":$.t("Off"), "class":"red"}],
"propValue":"Cmd",
"propValueAjax":"command"});

PlanningTimerSheet(options);//Update for Planning
}
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Weekly programming

Post by bigpea »

Yes, perfect, all clear!
Now it works! :D thanks
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

Good news!
Could you post a screen capture of your work? :)
Have a nice WE.
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Weekly programming

Post by bigpea »

Yes sure but I have to upload from my PC, via Mobile phone I have some problem.
In order to complete the work I have to complete few details but I’m very happy as first result! Many thanks for your works!
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Weekly programming

Post by bigpea »

as promised, this is the final result.
as told I have to solve some issue, but as first result is very good (for me, sure :) )
screen.png
screen.png (102.85 KiB) Viewed 3676 times
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

Thank you
Nice job! :)
Patricen
Posts: 108
Joined: Tuesday 06 February 2018 18:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta rel
Contact:

Re: Weekly programming

Post by Patricen »

Hello,
Great job!
An improvement idea :
when using a setpoint (thermostat for example), would it be possible triggering "Comfort", "Night", "Vacation" from a blockly event that would supersede the scheduled setpoints and would allow saving energy while out of home?

Patrice
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

Hi @Patricen

If I understand your request to "override" the planning with a predefined temperature command, you can already do that with a virtual selector switch.
You just have to rename each level by "Comfort", "Night", ... and associate to each level an action to set the setpoint to your predefined temperature with the API command like :

Code: Select all

json.htm?type=command&param=setsetpoint&idx=YOUR_SETPOINT_ID&setpoint=TEMPERATURE
for instance for "Confort":

Code: Select all

json.htm?type=command&param=setsetpoint&idx=2&setpoint=21
for "Night":

Code: Select all

json.htm?type=command&param=setsetpoint&idx=2&setpoint=18
BUT, I realized that setpointtimers have to be disabled too. I think it would required a script to do all this stuff.
Patricen
Posts: 108
Joined: Tuesday 06 February 2018 18:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta rel
Contact:

Re: Weekly programming

Post by Patricen »

Hi, @Syrhus,

I'm currently struggling with a blockly "script" to try proceeding to this, but it looks like the script is only triggered when the virtual selector switch state changes. I then check actual T°(compared to the Eco value I set to 16° for example) + selector position as if planning schedule temperature changes while selector is in Eco mode, temperature setpoint will follow planning schedule and not selector switch position.

The issue is as follows : If selector goes back to "Normal" instead of "Eco", is there a way to grab out schedule temperature to go out of "Eco" setpoint?
Attachments
Blockly.png
Blockly.png (25.46 KiB) Viewed 3601 times
Patricen
Posts: 108
Joined: Tuesday 06 February 2018 18:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta rel
Contact:

Re: Weekly programming

Post by Patricen »

Update :
I found out some tricks :
In order to freeze "Away" mode, I check if setpoint temp is different from Away setpoint (16°C for this case) and if Away is selected. If setpoint temperature has changed, this means schedule is running and comfort/eco has been triggered.
Then, as the setpoint changes according to the schedule, it is stored in a user's variable to be able restoring it when switch is changed from "Away" to "PGM".

If "Away" goes back to "PGM", I'd like to restore the value as the current setpoint
The issue is that it is not possible to set a temperature as a variable, only digits can be used.

Any clue?
Attachments
Blockly.png
Blockly.png (40.7 KiB) Viewed 3587 times
syrhus
Posts: 79
Joined: Tuesday 12 December 2017 14:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Paris
Contact:

Re: Weekly programming

Post by syrhus »

Hi Patrice

As I'm not sure to understand what you're trying to achieve with your blocky script,so I've done this with a lua script; you can either choose Automatic to follow the planning or Comfort,Eco,Freeze protection to force the predefined temperature and disable all setpointtimer to avoid a new plannig setpoint trigger.
thermostat switch.PNG
thermostat switch.PNG (31.75 KiB) Viewed 3562 times

Code: Select all

-- Definitions
commandArray = {}
local DOMOTICZ_IP = '127.0.0.1:8080'
local DEVICE = "THE NAME OF YOUR VIRTUAL THERMOSTAT SWITCH" --In my sample, "Thermostat Switch"
local DEVICE_ID = YOUR_SETPOINT_DEVICE_ID

-- Main script
if devicechanged[DEVICE] then 
    
    json = assert(loadfile '/home/pi/domoticz/scripts/lua/JSON.lua')()  -- For Linux
    --   json = (loadfile "D:\\Domoticz\\scripts\\lua\\json.lua")()  -- For Windows
    
    --load all setpointtimers for the DEVICE_ID
    local url = 'http://'..DOMOTICZ_IP..'/json.htm?type=setpointtimers&idx='..DEVICE_ID
    --print (url)
    local config=assert(io.popen('curl "' .. url .. '"'))
    
    local blocjson = config:read('*all')
    config:close()
    --print ('blocjson:' .. blocjson)
    local jsonResult = json:decode(blocjson).result

    local vrb= "disablesetpointtimer";
    local NewLevel = devicechanged[DEVICE];
    print ('New level command:' .. NewLevel)
    if NewLevel == "Automatic" then
        vrb = "enablesetpointtimer";
    else
   	local temp = 6
        if NewLevel == "Comfort" then
            temp = 21
        elseif NewLevel == "Economic" then
            temp = 18
        end
        
        --update the Setpoint to the predefined temperature
        commandArray['UpdateDevice'] = DEVICE_ID .. "|0|" .. temp
    end
    
    --change all setpointtimers of DEVIDE_ID to the desired state : disabled of enabled
    for i,setpoint in ipairs(jsonResult) do
        os.execute ('curl "http://' .. (DOMOTICZ_IP) .. '/json.htm?type=command&param='..vrb..'&idx=' .. (setpoint.idx) ..'"');
    end
end 

return commandArray
Would it be good for you with this?
Patricen
Posts: 108
Joined: Tuesday 06 February 2018 18:48
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta rel
Contact:

Re: Weekly programming

Post by Patricen »

Thanks,
I'll check that, as I'm a newbie with lua scripts and will let you know.
hpadmin
Posts: 6
Joined: Tuesday 27 February 2018 13:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Weekly programming

Post by hpadmin »

bigpea wrote: Monday 19 February 2018 9:21 as promised, this is the final result.
as told I have to solve some issue, but as first result is very good (for me, sure :) )

screen.png
Wow, wonderful dashboard. Now i have Monitor Le TUTO, bur your dash is better. Do you have code ... or download ...its public ? Thx
bigpea
Posts: 91
Joined: Thursday 11 August 2016 12:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: IT
Contact:

Re: Weekly programming

Post by bigpea »

hpadmin wrote: Tuesday 27 February 2018 13:50 Wow, wonderful dashboard. Now i have Monitor Le TUTO, bur your dash is better. Do you have code ... or download ...its public ? Thx
Thanks, I'm finishing the dashbord, as soon I will finish I will public the code :)
opentoideas
Posts: 14
Joined: Friday 02 March 2018 16:31
Target OS: Windows
Domoticz version: 3.8153
Location: Bristol UK
Contact:

Re: Weekly programming

Post by opentoideas »

Hi, I am excited by the possibilities of this but I am new to Domoticz and scripting and am struggling to get this to work.

I have changed the files I think as you have described but did notice that in the UtilityController.js on the second addition that my async value was false not true as in your instructions so I am not sure that i have made the amendments correctly.

I have attached my attempt at the amended files. would you mind having a look to see what I have done wrong?

I tried both deleting the browser cashe and restarted the service but still do not get the planning button.

If you can take the time to have a look I am sure I have done something stupid as I do not yet understand scripting but hope you wont mind.
LightsController.js
(176.52 KiB) Downloaded 92 times
Last edited by opentoideas on Saturday 03 March 2018 11:50, edited 1 time in total.
opentoideas
Posts: 14
Joined: Friday 02 March 2018 16:31
Target OS: Windows
Domoticz version: 3.8153
Location: Bristol UK
Contact:

Re: Weekly programming

Post by opentoideas »

hmm sorry only letting me add one file
Attachments
UtilityController.js
(87.16 KiB) Downloaded 110 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest