Creating a new virtual device seems to always assing an alphanumeric id. I'm trying to give this device a value on a lua script without success.
Update device always expects an integer idx and doesn't set my virtual temperature device.
And a commandArray assign throws error as well: Error: EventSystem: commandArray in script script_time_SetTemp should only return ['string']='actionstring' or [integer]={['string']='actionstring'}
Does anyone knows how to make this?
Thanks.
Set value of virtual device with alphanumerical idx
Moderator: leecollings
Re: Set value of virtual device with alphanumerical idx
You probably missing some quotes, or forgot to convert a type. Post your code, so we can look at it.
-
- Posts: 39
- Joined: Friday 12 December 2014 13:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9639
- Location: Spain
- Contact:
Re: Set value of virtual device with alphanumerical idx
Thank you trixwood and sorry, I've been busy from stomach illness.trixwood wrote:You probably missing some quotes, or forgot to convert a type. Post your code, so we can look at it.
I'm using the script for getting temperature from THB sensor at the wiki. I've been trying some things so the script is messed.
Code: Select all
--Script To Parse WeatherUnderground Multi-Value Sensor, Additionally using PWS: system from WU with a new output format
--This script assumes the output (which can be viewed in events show current state button) is like this 19.5;79;3;1019;3 (temp;humidity;null;pressure;null)
--more details at this wiki http://www.domoticz.com/wiki/Virtual_weather_devices
--The following need updated for your environment get the 'Idx' or 'Name' off the Device tab. By default only the Temp is 'uncommented or enabled' in this script.
local sensorwu = 'WUTHB' --name of the sensor that gets created when you add the WU device (and that contains multiple values like temperature, humidity, barometer etc)
local idxt = '140BD' --idx of the virtual temperature sensor you need to change this to your own Device IDx
--local idxh = 999 --idx of the virtual humidity sensor you need to change this to your own Device IDx
--local idxp = 999 --idx of the virtual pressure sensor you need to change this to your own Device IDx
commandArray = {}
--if devicechanged[sensorwu] then
sWeatherTemp, sWeatherHumidity, sHumFeelsLike, sWeatherPressure = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
sWeatherTemp = tonumber(sWeatherTemp)
sWeatherHumidity = tonumber(sWeatherHumidity)
sWeatherPressure = tonumber(sWeatherPressure)
print('WU Script Parsed Temp=' .. sWeatherTemp .. ' Humidity=' .. sWeatherHumidity .. ' Pressure=' .. sWeatherPressure)
commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. tostring(sWeatherTemp)}
-- commandArray[1] = {['UpdateDevice'] = tostring(idxt) .. '|0|' .. tostring(sWeatherTemp)}
--commandArray[2] = {['UpdateDevice'] = idxh .. '|' .. tostring(sWeatherHumidity) .. '|' .. tostring(sHumFeelsLike)}
--commandArray[3] = {['UpdateDevice'] = idxp .. '|0|' .. tostring(sWeatherPressure) .. ';' .. tostring(sWeatherPressForcast)}
-- myjson = 'http://192.168.11.245/json.htm?type=command¶m=udevice&idx='..tostring(idxt)..'&nvalue=0&svalue='..tostring(sWeatherTemp)
-- commandArray['OpenURL'] = myjson
-- print('json= ' .. myjson)
-- commandArray['WUTemp']=sWeatherTemp
--end
return commandArray
-
- Posts: 30
- Joined: Friday 12 December 2014 11:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: UK
- Contact:
Re: Set value of virtual device with alphanumerical idx
here you go.
Code: Select all
i=0
help="big boy"
idx="173"
i=i+1
commandArray[i]={['UpdateDevice']=idx..'|0|'..help}
-
- Posts: 39
- Joined: Friday 12 December 2014 13:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9639
- Location: Spain
- Contact:
Re: Set value of virtual device with alphanumerical idx
Thanks pdjm43, but note the problem here is that the destination idx is alphanumerical. Aka "140BD" in my system.pdjm43 wrote:here you go.
...
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: Set value of virtual device with alphanumerical idx
@Sergio, Are you sure that is the IDX and not the ID you refer to?
Jos
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 39
- Joined: Friday 12 December 2014 13:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.9639
- Location: Spain
- Contact:
Re: Set value of virtual device with alphanumerical idx
Look, you're absolutely right. I confused the Id with idx.
Now it works! Well... I feel stupid.
But now, I see that I have two devices with same id. Should that be why I couldn't work with "IsDark" on blocky lately.
It's normal?


But now, I see that I have two devices with same id. Should that be why I couldn't work with "IsDark" on blocky lately.

It's normal?
Who is online
Users browsing this forum: No registered users and 1 guest