Access temperature readings from 5104DTSI in LUA

Discussion in 'C-Bus Automation Controllers' started by Damaxx, Feb 23, 2018.

  1. Damaxx

    Damaxx

    Joined:
    May 12, 2008
    Messages:
    226
    Likes Received:
    47
    Looking to get temp readings from a 4 channel temperature sensor in scripting, but not having any luck
    The helper code snippet shows the following -
    Code:
    -- Get temperature and units of channel 1 of sensor 1 on the local network
    -- temp is a float and units is a string (eg '°C')
    temp, units = GetCBusMeasurement('Local', 'sensor1', 1) 
    And the C-Bus function code snippet shows
    Code:
     GetCBusMeasurement(net, ua, channel)
    So my temp sensor is network 254 and address 33
    Code:
     temp, units = GetCBusMeasurement(254, 33, 1) 
    And I get the following error - Library cbuslogic:0: unable to find 254/228/33/1 stack traceback: [C]: in function 'error' Library cbuslogic: in function 'GetCBusMeasurement'

    So I tried the measurement device ID (I know, but I figured what the hell) - 166 and got the same error

    upload_2018-2-24_5-41-18.png

    What have I missed?
     
    Damaxx, Feb 23, 2018
    #1
  2. Damaxx

    Daggo

    Joined:
    Feb 21, 2018
    Messages:
    13
    Likes Received:
    0
    Hi
    Maybe your network address should be the name not the number, same as the sensor unit address.
    temp, units = GetCBusMeasurement('networkname', 'unitname', 1)

    I don't have a temp sensor to test with.

    Not sure what the automation controller will do with that data either you may need to set another object with the value returned from that query.
     
    Daggo, Feb 24, 2018
    #2
  3. Damaxx

    Damaxx

    Joined:
    May 12, 2008
    Messages:
    226
    Likes Received:
    47
    Thanks Daggo. LUA script will accept either network name or address.
    Will add some more script once I stop getting errors, ie. log(temp) for debugging.
     
    Damaxx, Feb 24, 2018
    #3
  4. Damaxx

    Damaxx

    Joined:
    May 12, 2008
    Messages:
    226
    Likes Received:
    47
    Discovered my issue - each channel needs an object created with the measurement ID and channel. Obviously this doesn't exist on Toolkit so never occurred to me.
    Although the script still faulted with 'unable to decode' error with the temp, units format, I removed the units format and it works perfectly (down to no less than 13 decimal places :) )
    Current temp - 29.3099994659424
     
    Damaxx, Feb 25, 2018
    #4
    MarkB, Ambro and Mr Mark like this.
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.