We have moved at community.getvera.com

Author Topic: Can anyone help with this script? Thermostat temp send to Domoticz  (Read 2135 times)

Offline Chrisfraser05

  • Sr. Member
  • ****
  • Posts: 451
  • Karma: +16/-31
Gents and Ladies,


I thought it was about time I learned a bit more about Lua and played around a bit more with scripting.

I've created a virtual temp sensor on Domoticz and I have tested sending the values to it, this works correctly using the following from "test lua" and from a scene.

local url = require("socket.url")
luup.inet.wget("http://192.168.1.66:8080/json.htm?type=command&param=udevice&idx=3&nvalue=0&svalue=15")


Now the Thermostat I want to take the current temp from is Vera device 49 (alt id for zwave 6).

I though I could use this code to extract the temp;

local CurrentTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 49)


The problem seems to be when I combine the two I am sending Zero, I guess I am reading Zero from the thermostat.


local CurrentTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 49)

local url = require("socket.url")
luup.inet.wget("http://192.168.1.66:8080/json.htm?type=command&param=udevice&idx=3&nvalue=0&svalue=CurrentTemp")


When I check the value in the device variables or check the value read into PLEG i was seeing a temp of 18.6 deg.

Can anyone see what I'm doing wrong?



For reference I use this code to read a temp from another sensor (child device) into a different thermostat and it works.

local CurrentTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 256)
luup.variable_set("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", CurrentTemp, 225)

Offline reneboer

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1574
  • Karma: +110/-31
Re: Can anyone help with this script? Thermostat temp send to Domoticz
« Reply #1 on: January 05, 2017, 07:26:00 am »
Hi,
Does this work?
luup.inet.wget("http://192.168.1.66:8080/json.htm?type=command&param=udevice&idx=3&nvalue=0&svalue="..CurrentTemp)

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline MarkAgain

  • Full Member
  • ***
  • Posts: 129
  • Karma: +3/-0
Re: Can anyone help with this script? Thermostat temp send to Domoticz
« Reply #2 on: January 05, 2017, 12:14:03 pm »
Not sure about the syntax of your application but I had to put the following code if front:

local status,

This gets the current temp from my Oregon weather station.  I think status is 0 or -1 for pass/fail and seems to be required.

local status, tmp  = luup.inet.wget("http://xxx.xxx.x.xxx:3480/data_request?id=variableget&DeviceNum=xx&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature")

Mark


Offline Chrisfraser05

  • Sr. Member
  • ****
  • Posts: 451
  • Karma: +16/-31
Re: Can anyone help with this script? Thermostat temp send to Domoticz
« Reply #3 on: January 05, 2017, 02:44:43 pm »
Hi,
Does this work?
luup.inet.wget("http://192.168.1.66:8080/json.htm?type=command&param=udevice&idx=3&nvalue=0&svalue="..CurrentTemp)

Cheers Rene

Thanks for your assistance guys.

local CurrentTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1", "CurrentTemperature", 49)

luup.inet.wget("http://192.168.1.66:8080/json.htm?type=command&param=udevice&idx=3&nvalue=0&svalue="..CurrentTemp)


this worked.

Now I just have to figure out why so I can work it out myself in future!