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.

Control Nefit boiler
#1
I like to control a Nefit boiler that has an EMS protocol. Its not possible to control it directly so i inserted an EMS-ESP into my system.

Now i can get data from my system with this script
Code:
--[[
Nefit heat pump ems bus
https://bbqkees-electronics.nl/wiki/gateway/restful-api.html
https://docs.emsesp.org/Commands/
ems-esp/boiler                                        {"cmd":"heatingactivated", "data":"on"}        turn on heatingactivated in boiler
ems-esp/boiler/heatingactivated        {"data":"on"}                                                            turn on heatingactivated in boiler (equivalent to command above)
ems-esp/boiler                                        {"cmd":"dhw.disinfecting", "data":"on"}        turn on DHW disinfecting in boiler
--]]

https = require('ssl.https')
json = require('json')
ltn12 = require('ltn12')

iDebug = true
devIp = '192.168.x.xx' -- ems-esp.local
devUrl = 'http://'..devIp..'/api/'

function getData(iFunction)
  if iDebug then log(devUrl..iFunction) end
  res, code = https.request({
      url = devUrl..iFunction,
      method = 'GET'
  })
  if iDebug then
      log(code, res)
  end
  return code, res
end

function setData(iFunction, iData)
  if iDebug then log(devUrl..iFunction) end
  res, code = https.request({
      url = devUrl..iFunction,
      method = 'POST',
      headers = {["content-type"] = "application/json"},
      data = iData
      })
  if iDebug then
      log(code, res)
  end
  return code, res
end

-- get system info
--getData('system')

-- get boiler info - GET outputs current EMS device information in verbose
--getData('boiler/info')

-- get boiler values - GET outputs current EMS device information in short format
--getData('boiler/values')

-- get boiler - GET    same as values above
--getData('boiler')

-- get boiler commands - GET    lists the available command entities to call
--getData('boiler/commands')

-- get boiler entities -     GET    lists all enabled entities
--getData('boiler/entities')

-- get boiler dhw info
--getData('boiler/dhw/info')

-- get boiler entity heatingactive
--getData('boiler/heatingactive')

-- thermostaat streeftemperatuur
--getData('thermostat/seltemp')

-- dhw Laden
--getData('thermostat/dhw/charge')
setData('thermostat/dhw/charge', '{"value": true}') --curl -X POST http:///api/system/dhw/charge -H "Content-Type: application/json" -d '{"value": true}'

I also like to control the data with the setData function (last line). But i received an error 400. Whats wrong with my code?

Documentation can be found here: https://docs.emsesp.org/Commands/
Reply


Messages In This Thread
Control Nefit boiler - by gjniewenhuijse - 26.09.2025, 12:53
RE: Control Nefit boiler - by admin - 26.09.2025, 12:58
RE: Control Nefit boiler - by gjniewenhuijse - 26.09.2025, 13:07
RE: Control Nefit boiler - by admin - 26.09.2025, 13:13
RE: Control Nefit boiler - by gjniewenhuijse - 26.09.2025, 13:20
RE: Control Nefit boiler - by admin - 26.09.2025, 13:27
RE: Control Nefit boiler - by gjniewenhuijse - 26.09.2025, 13:33
RE: Control Nefit boiler - by admin - 26.09.2025, 13:39
RE: Control Nefit boiler - by gjniewenhuijse - 26.09.2025, 13:49
RE: Control Nefit boiler - by admin - 26.09.2025, 14:05
RE: Control Nefit boiler - by maxmp - 26.09.2025, 21:00
RE: Control Nefit boiler - by gjniewenhuijse - 29.09.2025, 08:58

Forum Jump: