Results 1 to 4 of 4

Thread: Require assistance with Insteon Lua Scripting getting temp from thermostat

  1. #1
    Join Date
    Apr 2006
    Posts
    3

    Default Require assistance with Insteon Lua Scripting getting temp from thermostat

    I'm trying to get the the room temp from my Venstar T1700 thermostat via Lua scripting. I have other programming knowledge, but cannot find syntax or examples for any Insteon Lua functions. This is what I'm trying to accomplish:

    Code:
    DeviceID = "01.74.A6"
    RoomTemp = nil
    
    --Make sure device exists, if not throw error
    local device = Insteon.DeviceManager:GetDevice(DeviceID)
    assert(device,'Device not found')
    
    --Get room temp from thermostat
    RoomTemp = Insteon.DeviceCommands.SendCommand(DeviceID,107,3)
    
    print(RoomTemp)
    When I run this code in the Lua Console I get the following response from Insteon: LOG: Insteon : 3 - CM: Receive: 01.74.A6 09.46.AA 38 107 146

    The number 146 at the end of the response in the console is the room temp times 2. I want to capture that number, divide it by 2 and put it in the RoomTemp variable. The problem is the Insteon.DeviceCommands.SendCommand function does not return a result into my variable.

    I'm not sure if anyone knows of a different Insteon function that would send 2 commands and return the result or if there is a way to just capture the number from the Lua Console.

    Any help is appreciate and please note that I'm a beginner to Lua scripting.

  2. #2
    Join Date
    Jun 2008
    Posts
    1,026

    Default

    i am in the middle of moving and all of my insteon stuff is down. the component doesn't support t stats yet. but you can do some simple stuff

    try

    local cb = function (code,results)

    print ('command code',code)

    if code == 'Ok' then
    table.print (results)
    end
    end


    local params = {
    Cmd1 = 107,
    Cmd2 = 3,
    Callback = cb,
    }

    device:SendInsteonMessage (params)


    the send message is asynchronous, hence the need for a callback.

    there is early framework in the component for the devcat 5 devices but i haven't looked at it in months.

  3. #3
    Join Date
    Apr 2006
    Posts
    3

    Default

    I tried your code:

    Code:
    DeviceID = "01.74.A6"
    
    local device = Insteon.DeviceManager:GetDevice(DeviceID)
    assert(device,'Device not found')
    
    local cb = function (code,results)
    	print ('command code',code)
    
    	if code == 'Ok' then
    		table.print (results)
    	end
    end
    
    local params = {
    	Cmd1 = 107,
    	Cmd2 = 3,
    	Callback = cb,
    }
    
    device:SendInsteonMessage(params)
    And I receive the following error:

    [string "Home Automation.gml:\Testing\Get Room Temp\..."]:25: attempt to call method `SendInsteonMessage' (a nil value)
    stack traceback:
    [string "Home Automation.gml:\Testing\Get Room Temp\..."]:25: in main chunk

    I don't think SendInsteonMessage is a function.

  4. #4
    Join Date
    Jun 2008
    Posts
    1,026

    Default

    its in devicebase.lua - wonder what is missing.

    you can inspect the object (device) by using the var inspector (F12).

    what does that look like?

    and you are using the Insteon Component - not the old plugin?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •