This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Ebeco floorheat thermostat
#15
(08.08.2022, 12:07)admin Wrote: This works for me using your credentials:
Code:
require('json')
require('ssl.https')
require('ltn12')

-- Set credentials for Ebecoconnect API
userNameOrEmailAddress = '...' -- your email for Ebecoconnect account
password = '...' -- your password for Ebecoconnect account

function GetToken()
  local response_body = {}
  local request_body = json.encode({
    userNameOrEmailAddress = userNameOrEmailAddress,
    password = password,
  })

  local body, code, hdrs, stat = ssl.https.request{
    url = 'https://ebecoconnect.com/api/TokenAuth/Authenticate',
    method = 'POST',
    headers = {
      ['Content-Type'] = 'application/json',
      ['Content-Length'] = #request_body,
      ['Abp.TenantId'] = 1,
    },
    source = ltn12.source.string(request_body),
    sink = ltn12.sink.table(response_body),
  }

  if code == 200 then
    local ret = table.concat(response_body)
    ret = json.pdecode(ret)

    if type(ret) == 'table' and type(ret.result) == 'table' then
      return ret.result.accessToken
    end
  else
    log('request failed', body, code, hdrs, stat)
  end
end

API_Token = GetToken()

function RequestFromEbeco(request, params)
  local url = 'https://ebecoconnect.com/api/services/app/Devices/' .. request
  local response_body = {}
  local request_body = ''
  local body, code, hdrs, stat = ssl.https.request{
    url = url,
    method = 'GET',
    headers = {
      ['Content-Type'] = 'application/json',
      ['Authorization'] = 'Bearer ' .. API_Token,
    },
    source = ltn12.source.string(request_body),
    sink = ltn12.sink.table(response_body),
  }
  if code == 200 then
    local ret = table.concat(response_body)
    ret = json.pdecode(ret)
    return ret
  else
    log('request failed', body, code, hdrs, stat)
  end
end

if API_Token then
  devices = RequestFromEbeco('GetUserDevices')
  log(devices)
end

Hi.

I´ve used this script for one device, but how do I get the data from data table 2-5?

Code:
if API_Token then
  devices = RequestFromEbeco('GetUserDevices')
  --log(devices)
end


  if devices and devices.result then
    for _, device in ipairs(devices.result) do
     
 
   
-- Enhetsdata 1
grp.checkwrite('32/2/1', device["id"]) -- id (Number)
grp.checkwrite('32/2/2', device["relayOn"]) -- relayOn (Bool)
grp.checkwrite('32/2/3', device["minutesToTarget"]) -- minutesToTarget (Number)
grp.checkwrite('32/2/4', device["temperatureRoom"]) -- temperatureRoom (Number)
grp.checkwrite('32/2/5', device["temperatureRoomDecimals"]) -- temperatureRoomDecimals (Number)
grp.checkwrite('32/2/6', device["temperatureFloorDecimals"]) -- temperatureFloorDecimals (Number)
grp.checkwrite('32/2/7', device["remoteInput"]) -- remoteInput (Bool)
grp.checkwrite('32/2/8', device["displayName"]) -- displayName (String)
grp.checkwrite('32/2/9', device["temperatureSet"]) -- temperatureSet (Number)
-- "errorMessage" ignorerad (userdata: NULL)
grp.checkwrite('32/2/10', device["building"]["name"]) -- building name (String)
grp.checkwrite('32/2/11', device["building"]["id"]) -- building id (Number)
grp.checkwrite('32/2/12', device["programState"]) -- programState (String)
grp.checkwrite('32/2/13', device["temperatureFloor"]) -- temperatureFloor (Number)
grp.checkwrite('32/2/14', device["hasError"]) -- hasError (Bool)
grp.checkwrite('32/2/15', device["installedEffect"]) -- installedEffect (Number)
grp.checkwrite('32/2/16', device["powerOn"]) -- powerOn (Bool)
grp.checkwrite('32/2/17', device["todaysOnMinutes"]) -- todaysOnMinutes (Number)
grp.checkwrite('32/2/18', device["selectedProgram"]) -- selectedProgram (String)

-- Enhetsdata 2
grp.checkwrite('32/2/19', device2["id"]) -- id (Number)
grp.checkwrite('32/2/20', device2["relayOn"] and 1 or 0) -- relayOn (Bool)
grp.checkwrite('32/2/21', device2["minutesToTarget"]) -- minutesToTarget (Number)
grp.checkwrite('32/2/22', device2["temperatureRoom"]) -- temperatureRoom (Number)
grp.checkwrite('32/2/23', device2["temperatureRoomDecimals"]) -- temperatureRoomDecimals (Number)
grp.checkwrite('32/2/24', device2["temperatureFloorDecimals"]) -- temperatureFloorDecimals (Number)
grp.checkwrite('32/2/25', device2["remoteInput"] and 1 or 0) -- remoteInput (Bool)
grp.checkwrite('32/2/26', device2["displayName"]) -- displayName (String)
grp.checkwrite('32/2/27', device2["temperatureSet"]) -- temperatureSet (Number)
-- "errorMessage" ignorerad (userdata: NULL)
grp.checkwrite('32/2/28', device2["building"]["name"]) -- building name (String)
grp.checkwrite('32/2/29', device2["building"]["id"]) -- building id (Number)
grp.checkwrite('32/2/30', device2["programState"]) -- programState (String)
grp.checkwrite('32/2/31', device2["temperatureFloor"]) -- temperatureFloor (Number)
grp.checkwrite('32/2/32', device2["hasError"] and 1 or 0) -- hasError (Bool)
grp.checkwrite('32/2/33', device2["installedEffect"]) -- installedEffect (Number)
grp.checkwrite('32/2/34', device2["powerOn"] and 1 or 0) -- powerOn (Bool)
grp.checkwrite('32/2/35', device2["todaysOnMinutes"]) -- todaysOnMinutes (Number)
grp.checkwrite('32/2/36', device2["selectedProgram"]) -- selectedProgram (String)
Reply


Messages In This Thread
Ebeco floorheat thermostat - by victor.back - 17.12.2021, 06:50
RE: Ebeco floorheat thermostat - by admin - 17.12.2021, 07:42
RE: Ebeco floorheat thermostat - by admin - 08.08.2022, 06:04
RE: Ebeco floorheat thermostat - by admin - 08.08.2022, 07:06
RE: Ebeco floorheat thermostat - by admin - 08.08.2022, 07:24
RE: Ebeco floorheat thermostat - by admin - 08.08.2022, 08:01
RE: Ebeco floorheat thermostat - by admin - 08.08.2022, 09:27
RE: Ebeco floorheat thermostat - by admin - 08.08.2022, 12:07
RE: Ebeco floorheat thermostat - by victor.back - 31.10.2023, 07:43
RE: Ebeco floorheat thermostat - by admin - 31.10.2023, 07:57

Forum Jump: