Arduino bibliotek (Gör din egen sensor)

Moderator: Telldus

bergetun
Posts: 17
Joined: Thu Jan 18, 2018 11:08 am

Re: Arduino bibliotek (Gör din egen sensor)

Post by bergetun » Tue Oct 08, 2019 10:25 pm

Thanks for trying to help me Micke, but i seem to need to have this in with a spoon :oops:

I think I understand the Sensortype flags, but i dont understand what the scale flags does. Is the sensortype and scale connected in some way ? How do i know witch one is supposed to be connected.

Lets say i have a sensor thats pops up as a temperature sensor in live.telldus.com called "MySensor" . I want this sensor to be converted to a "Volt sensor"

Will this psudo lua code do the trick to convert the temperature sensor to a volt sensor in live.telldus.com ? I am using the sensortype "UNKNOWN" beacuse i dont know witch one to use with the SCALE_POWER_VOLT scaletype.

Code: Select all

SCALE_POWER_VOLT = 4
UNKNOWN = 0

local deviceManager = require "telldus.DeviceManager"
local sensor = deviceManager:findByName("MySensor")

function onSensorValueUpdated(device, valueType, value, scale)
   if device:id() == sensor:id()
   {
         sensor:setSensorValue(UNKNOWN, value, SCALE_POWER_VOLT)
   }

I really appriciate your help

micke.prag
Site Admin
Posts: 2233
Joined: Thu Jan 18, 2018 11:08 am
Location: Lund
Contact:

Re: Arduino bibliotek (Gör din egen sensor)

Post by micke.prag » Wed Oct 09, 2019 7:39 am

Scales are depending on the sensor type. For instance Celcius can only be used together with Temperature. In your case you need to specify valueType=POWER.

Code: Select all

SCALE_POWER_VOLT = 4
VALUE_TYPE_POWER = 256

local deviceManager = require "telldus.DeviceManager"
local sensor = deviceManager:findByName("MySensor")

function onSensorValueUpdated(device, valueType, value, scale)
   if device:id() == sensor:id()
   {
         sensor:setSensorValue(VALUE_TYPE_POWER, value, SCALE_POWER_VOLT)
   }
Micke Prag
Software
Telldus Technologies

bergetun
Posts: 17
Joined: Thu Jan 18, 2018 11:08 am

Re: Arduino bibliotek (Gör din egen sensor)

Post by bergetun » Wed Oct 09, 2019 11:58 am

Fantastic @Micke, it works :)

Thank you so much for your help.

The only issue i have now is that the sensor pops up with both Voltage and Temperature with the same value (See attachment)

Is it possible to remove the Temperature part of the sensor.?

Maybe its possible to create a dummy sensor with only voltage with values from a real sensor?

Image

micke.prag
Site Admin
Posts: 2233
Joined: Thu Jan 18, 2018 11:08 am
Location: Lund
Contact:

Re: Arduino bibliotek (Gör din egen sensor)

Post by micke.prag » Thu Oct 10, 2019 9:31 am

Unfortunately you cannot do this yourself (yet). Contact the support, they can help you.
Micke Prag
Software
Telldus Technologies

Post Reply