-
-
Notifications
You must be signed in to change notification settings - Fork 5
ioBroker Integration
Elias Ruemmler edited this page Jul 17, 2024
·
11 revisions
Define a new device (e.g. "Temp2IoT") under userdata with one state for the temperature measvalue.
Device and state tree:
State settings:
Set the type to numeric
and add a unit
attribute if needed.
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);
});
});
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');
}
});