Hi everyone,
I was wonder if Device Change command in Lua also applicable to the virtual device in thermostat type.
For example I would like to turn on a switch / light / or something if the set temperature of the thermostat has been changed.
Some thing like
if Device thermostat = "changed" then
Commandarray = switch == On
Or is there other suggestion ?
thanks
Lua virtual device thermostat device change
Moderators: leecollings, Stuntteam
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Lua virtual device thermostat device change
That should work fine. Did you actually give it a try to see what happens as the shown code doesn't have the proper syntax?
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 33
- Joined: Wednesday 23 December 2015 11:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: Lua virtual device thermostat device change
Thanks jvdz. No I have not tried it yet. It was just a quick type example. And I don't know the proper syntax either. I could not find the correct syntax for the device change. The wiki page only show the example of device change == on. That's why I was wondering if my idea was possible.
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Lua virtual device thermostat device change
This would be a good point to start in case you want to write LUA scripts: https://www.domoticz.com/wiki/Events
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 33
- Joined: Wednesday 23 December 2015 11:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: Lua virtual device thermostat device change
I did something like this but does not work
--Thermostat setpoint
local WNKT = '1 thermostat'
local HSLPT = '2 Thermostat'
local KLNKT = '3 thermostat'
--Maxscript (Virtual switch)
local Max ="Maxscript"
commandArray = {}
if (devicechanged[WKT] == true or devicechanged[HSLPT] == true or devicechanged[KLNKT] == true) then
print('Run Maxscript')
commandArray[Max]='On AFTER 3'
end
return commandArray
--Thermostat setpoint
local WNKT = '1 thermostat'
local HSLPT = '2 Thermostat'
local KLNKT = '3 thermostat'
--Maxscript (Virtual switch)
local Max ="Maxscript"
commandArray = {}
if (devicechanged[WKT] == true or devicechanged[HSLPT] == true or devicechanged[KLNKT] == true) then
print('Run Maxscript')
commandArray[Max]='On AFTER 3'
end
return commandArray
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Lua virtual device thermostat device change
The devicechanged table will contain the device(s) changed and their new value while you compare them to true.
try:
Jos
try:
Code: Select all
- Thermostat setpoint
local WNKT = '1 thermostat'
local HSLPT = '2 Thermostat'
local KLNKT = '3 thermostat'
--Maxscript (Virtual switch)
local Max = "Maxscript"
commandArray = {}
if (devicechanged[WKT] or devicechanged[HSLPT] or devicechanged[KLNKT]) then
print('Run Maxscript')
commandArray[Max] = 'On AFTER 3'
end
return commandArray
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 33
- Joined: Wednesday 23 December 2015 11:27
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: Lua virtual device thermostat device change
jvdz
YOU ARE AWESOME.
Thanks a lot.
I though DeviceChanged only respons to 'On' or 'Off'
YOU ARE AWESOME.
Thanks a lot.
I though DeviceChanged only respons to 'On' or 'Off'
-
- Posts: 105
- Joined: Saturday 25 November 2017 17:18
- Target OS: Raspberry Pi / ODroid
- Domoticz version: v3.8153
- Location: Czech Rep.
- Contact:
Re: Lua virtual device thermostat device change
Hi.
I am using thermostat too.
Here is my examples of my action, if thermostat setpoint is changed.
In my case, it sends command to my device with setpoint value, but you can write your own action.
LUA:
But I prefer dzVents now:
I am using thermostat too.
Here is my examples of my action, if thermostat setpoint is changed.
In my case, it sends command to my device with setpoint value, but you can write your own action.
LUA:
Code: Select all
commandArray = {}
if devicechanged['Kacka_Setpoint'] then
DomDevice = 'Kacka_Setpoint'
DomValue = otherdevices_svalues[DomDevice]
CalcValue = (DomValue*1)
print(CalcValue)
url= 'http://192.168.1.102/control?cmd=event,HeatSetpoint='..(CalcValue)..''
print(url)
commandArray['OpenURL']= url
end
return commandArray
Code: Select all
return {
active = true, -- set to false to disable this script
on = {
devices = {
'Kacka_Setpoint'
}
},
execute = function(domoticz, device)
local url= 'http://192.168.1.102/control?cmd=event,HeatSetpoint='..(device.state)..''
print(url)
domoticz.openURL(url)
end
}
RPi2 Domoticz v 4.10717
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
10 x Sonoff Basic - ESPeasy
1 x Wemos D1 - ESPeasy
1 x Shelly Plus Plug S
1 x Sonoff S26 - ESPeasy
1 x Shelly 1
1 x MySensors HC-SR04
1 x MySenosrs wifi gateway
1 x RFLink
4x Cam IPC-T240H
Who is online
Users browsing this forum: No registered users and 1 guest