Skip to content

ioBroker Integration

Elias Ruemmler edited this page Jul 17, 2024 · 11 revisions

Objects

Define a new device (e.g. "Temp2IoT") under userdata with one state for the temperature measvalue.

Sample

Device and state tree: ioBroker objects

State settings: ioBroker objects Set the type to numeric and add a unit attribute if needed.

Script

Create a new script:

const url = 'http://<Temp2IoT IP>/api';
const idTemp1 = '0_userdata.0.Temp2IoT.Temperatur_Water';
const idTemp2 = '0_userdata.0.Temp2IoT.Temperatur_Ambi';
 

schedule('* * * * *', function() { //every minute
    request(url, function(error, response, result) {
        let obj = JSON.parse(result);
        setState(idTemp1,  parseFloat(obj.sensors['0'].value), true);
        setState(idTemp2,  parseFloat(obj.sensors['1'].value), true);
    });
});

Script with axios.get():

const axios = require('axios');

const url = 'http://<Temp2IoT IP>/api';
const idTemp1 = '0_userdata.0.Temp2IoT.Temperatur_Water';
const idTemp2 = '0_userdata.0.Temp2IoT.Temperatur_Ambi';
 

schedule('* * * * *', async function() { //every minute
    try
    {
        let response = await axios.get(url);
        let obj = response.data;
        setState(idTemp1, obj.sensors['1'].value, true);
        setState(idTemp2, obj.sensors['2'].value, true);
    }
    catch (error)
    {
        log(exMsg, 'error');
    }
});

Sample view in ioBroker

ioBroker objects

Clone this wiki locally