26.09.2025, 12:53
(This post was last modified: 26.09.2025, 12:55 by gjniewenhuijse.)
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
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/
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/