I want to set the temperature of a virtual device using something like...
commandArray['Temperature House'] = tostring(current)
.. which doesn't work. How can I do this without using the IDX?
Set Temperature using Lua
Moderator: leecollings
-
- Posts: 115
- Joined: Saturday 21 December 2013 23:50
- Target OS: Linux
- Domoticz version:
- Location: Scotland
- Contact:
Set Temperature using Lua
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
- oeildefeu
- Posts: 9
- Joined: Saturday 28 December 2013 15:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: France
- Contact:
Re: Set Temperature using Lua
why without IDX ?
Raspberry Pi 3 - Raspbian + Razberry (OpenZwave) + RFXtrx433
-
- Posts: 115
- Joined: Saturday 21 December 2013 23:50
- Target OS: Linux
- Domoticz version:
- Location: Scotland
- Contact:
Re: Set Temperature using Lua
Because I want to define the dummy temperature device by name (as a variable), and don't want to have to specify the IDX as well.
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
-
- Posts: 115
- Joined: Saturday 21 December 2013 23:50
- Target OS: Linux
- Domoticz version:
- Location: Scotland
- Contact:
Re: Set Temperature using Lua
anyone?
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
Re: Set Temperature using Lua
Think that this option can't be enabled at the moment in lua.
you have to use the idx format
you have to use the idx format
- jvdz
- Posts: 2330
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Set Temperature using Lua
This is an example of a script that can retrieve the IDX for a devicename which you then can use to set an device with its IDX:
The required libraries and how to install can be found in the DTGBOT wiki.
Jos
Code: Select all
commandArray = {}
-- Load necessary Lua libraries
http = require "socket.http";
JSON = require "JSON";
server_url="http://192.168.0.xx:8080"
-- Function to retrieve the IDX for a DeviceName
function GetDeviceIDX(DeviceName)
-- get device IDX from Domotics
local DeviceIDX,result,record
DeviceIDX = 99999
DeviceURL="type=devices&order=name&used=true"
t = server_url.."/json.htm?" .. DeviceURL
jresponse, status = http.request(t)
decoded_response = JSON:decode(jresponse)
result = decoded_response['result']
for i = 1, #result do
record = result[i]
if record['Name'] == DeviceName then
DeviceIDX=record['idx']
break
end
end
return DeviceIDX
end
DeviceName="ThermostaatHK"
DeviceIDX = GetDeviceIDX(DeviceName)
if DeviceIDX == 99999 then
print(" DeviceName "..DeviceName.." not found.")
else
print(" DeviceName "..DeviceName.." DeviceIDX="..DeviceIDX)
end
return commandArray
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 115
- Joined: Saturday 21 December 2013 23:50
- Target OS: Linux
- Domoticz version:
- Location: Scotland
- Contact:
Re: Set Temperature using Lua
thanks!!
My Setup: Pi, RFXtrx433, HomeEasy: 13 Dimmers & 4 Sockets, 2 motion-sensors, 3 magnetic switches, 1 OWL Electricity Sensor, 3 Oregon Temp Sensor.
Who is online
Users browsing this forum: No registered users and 1 guest