Virtual device for temperature offset?

Hi,

I don’t seem to figure out the following problem:

  • I bought several Aeon Gen5 multisensors but their temperature reading is off (by as much as 2…2,5 degrees C).
    There is no way to calibrate the temperature reading in that multisensor itself, so Aeon helpdesk suggested to use TemperatureFix plugin. But it seems to me that this plugin is unstable (at least in my Vera Edge under UI7).

I’ve found this topic: http://forum.micasaverde.com/index.php/topic,15733.0.html and tried to use it as an example for creating similar Virtual Device for temperature correction.
But I can’t seem this to work.

Here’s my code:

  1. For the Virtual Device:
    Device type: urn:schemas-micasaverde-com:device:TemperatureSensor:1
    Upnp Device Filename: D_TemperatureSensor1.xml

  2. The scene to feed data to this Virtual Device:
    local IDTkab = 9 – Device ID of actual device
    local IDVkab = 14 – Device ID of dummy device
    local MuudaKab = 2 – Amount to adjust Temperature
    local TempAadress = “urn:micasaverde-com:serviceId:TemperatureSensor1”

local HetkeTKab = luup.variable_get(TempAadress,“CurrentLevel”,IDTkab)
local UusTKab = HetkeTKab + MuudaKab
luup.variable_set(TempAadress,“CurrentLevel”,UusTKab,IDVkab)

Can you find what’s wrong?

Your problem is that the example you followed was for a virtual humidity device, abut you are trying to do something similar for temperature. The difference is the name of the temperature device variable which should be CurrentTemperature, not CurrentLevel. Also, your serviceId should be urn:upnp-org:serviceId:TemperatureSensor1 and not urn:micasaverde-com:serviceId:TemperatureSensor1.

Make those changes to your code and it may work better.

Thank you very much! With these changes it works!
I had actually tried to use “upnp.org” in the service address but that alone didn’t help - it seems the main error was incorrect use of “CurrentLevel” instead of “CurrentTemperature”.

Actually also other readings between the different multisensors are pretty inconsistent (I have two Aeon Gen5 multisensors laying side-by-side - one showing 63 lux, another 47 lux), so I was thinking to write a virtual device also for lux (light intensity) measurement.

No need to say, I got stuck with that too. :slight_smile:

This is how I was trying to script it:

  • created a virtual device:
    Device type - urn:schemas-micasaverde-com:device:LightSensor:1
    Device file - D_LightSensor1.xml

  • added the following lines in my scene (which repeats every five minutes, already correcting temperature readings for virtual temperature devices):
    local ValgusTubaA = 10 – Device ID of actual device
    local ValgusTubaV = 16 – Device ID of dummy device
    local ValguseMuutus_Tuba = 1.2 – Amount to adjust Light
    local LightService = “urn:upnp-org:serviceId:LightSensor1”

local HetkeValgus_Tuba = luup.variable_get(LightService,“CurrentValue”,ValgusTubaA)
local UusValgus_Tuba = HetkeValgus_Tuba*ValguseMuutus_Tuba
luup.variable_set(LightService,“CurrentValue”,UusValgus_Tuba,ValgusTubaV)

Can you find what’s wrong here? Does CurrentValue need to be substituted with something more suitable?
I tried to find a list of all “Current…” variable definitions but didn’t; probably can’t look in the right places - I’m quite new to Luup but willing to learn :slight_smile: .

To find these, go to the “advanced tab” of the device you are interested in. You’ll see all the variables there. Hover your mouse over the variable you are interested in and you’ll see the service ID.

Thank you!
Sorry if I was unclear, what I meant was - there is “CurrentTemperature”, then “CurrentLevel”… Is there some other “CurrentXYZ” expressions, for example a “CurrentLightIntensity” or something like that?

The names are little to do with Vera, per se, but more about the definition of UPnP. Where standard definitions were missing, Vera created some of their own. Other developers do their own thing too.

This may also be compounded in you case for the light level. Last time I looked at this files, they were incompletely buildt on another sensor (IIRC, humidity) so the names were wrong anyway.

It’s, basically, a mess.

Ok, another proof that home automation universe is still in quite early development phases (not prototypes any more, but clearly not established and proven standards).

Other than that - does the syntax below look correct to you?
(I’ve translated the names so it makes more sense in English)

=============
local RoomLightActual = 10 – Device ID of actual device
local RoomLightVirtual = 16 – Device ID of dummy device
local LightChange_Room = 1.2 – Amount to adjust Light
local LightService = “urn:upnp-org:serviceId:LightSensor1”

local CurrentLight_Room = luup.variable_get(LightService,“CurrentValue”,RoomLightActual)
local NewLight_Room = CurrentLight_Room*LightChange_Room
luup.variable_set(LightService,“CurrentValue”,NewLight_Room,RoomLightVirtual)

Quite so.

Other than that - does the syntax below look correct to you? (I've translated the names so it makes more sense in English)

I was quite enjoying the Estonian?

You might want to round the result to a whole number. There are different ways to do this, but I quite like this (there is otherwise no ‘round’ function in Lua, although you could use ‘math.floor’ instead):

local RoomLightActual = 10     -- Device ID of actual device
local RoomLightVirtual = 16      -- Device ID of dummy device
local LightChange_Room = 1.2    -- Amount to adjust Light
local LightService = "urn:upnp-org:serviceId:LightSensor1"

local round = "%0.0f"

local CurrentLight_Room = luup.variable_get(LightService,"CurrentValue",RoomLightActual)
local NewLight_Room = round: format (CurrentLight_Room*LightChange_Room)

luup.variable_set(LightService,"CurrentValue",NewLight_Room,RoomLightVirtual)

Thank you so much jswim788 and akbooer!
I finally got that one to work also.

It shows the main reason for not working was

  1. it needed “CurrentLevel” instead of “CurrentValue”, and
  2. correct urn was “urn:micasaverde-com:serviceId:LightSensor1” (so micasaverde-com instead of upnp-org).

I did find both under “Advanced - Variables” tab of the actual (physical) device, as user jswim788 said, although I had to look twice to realize I had them there.

I also implemented the rounding function from the last post - it makes sense to display only round numbers for a value which can range from 0 to 1000 (and beyond).

The working code:

[code]local RoomLightActual = 10 – Device ID of actual device
local RoomLightVirtual = 16 – Device ID of dummy device
local LightChange_Room = 1.2 – Amount to adjust Light

local round = “%0.0f”

local LightService = “urn:micasaverde-com:serviceId:LightSensor1”

local CurrentLight_Room = luup.variable_get(LightService,“CurrentLevel”,RoomLightActual)
local NewLight_Room = round: format (CurrentLight_Room*LightChange_Room)
luup.variable_set(LightService,“CurrentLevel”,NewLight_Room,RoomLightVirtual)[/code]

By the way - does the expression “urn:micasaverde-com:serviceId:LightSensor1” make this scene internet-dependent?
In other words, does it go looking for something at micasaverde.com server every time it runs?
And if the internet connection is down, the scene doesn’t run?

Sorry, newbie questions :slight_smile:

No, absolutely not. It’s just a naming convention so as to give at least some clue as to who created it.