[HOW TO] Advanced Virtual Device for ESPAltherma

const b_ip = ‘192.168.2.61’;
const b_baseurl = ‘http://’+ b_ip + ‘/getData’;

function toFixed(num) {
return Math.trunc((num * 100) / 100);
}

data = {};

try {
const res = await fetch(b_baseurl);
if (res.ok) data = await res.json();
} catch (err) {
log(err);
}

let ops = ;

altherma = {};
switch(data[‘Operation Mode’]) {
case ‘Fan Only’:
altherma[‘mode’] = ‘Fan Only’;
break;
case ‘Heating’:
altherma[‘mode’] = ‘Heating’;
break;
case ‘Cooling’:
altherma[‘mode’] = ‘Cooling’;
break;
default:
altherma[‘mode’] = data[‘Operation Mode’];
}

switch(data[‘I/U operation mode’]) {
case ‘DHW’:
altherma[‘status’] = ‘On’;
altherma[‘mode’] = ‘DHW’;
break;
case ‘Stop’:
altherma[‘status’] = ‘-’;
break;
default:
altherma[‘status’] = ‘On’;
}
//if (altherma[‘status’] == ‘Stop’) altherma[‘status’] = ‘Off’;

let voltage = Math.min(230, data[‘Voltage (N-phase) (V)’]);

altherma[‘heat_pump_power’] = (data[‘INV primary current (A)’] * voltage);
altherma[‘heat_pump_power_2’] = (data[‘INV secondary current (A)’] * voltage);
altherma[‘valve_2way’] = (data[‘2way valve(On:Heat_Off:Cool)’] == ‘ON’ ? ‘Heat’ : ‘Cool’) + ’ (‘+ data[‘2way valve(On:Heat_Off:Cool)’] +’)‘;
altherma[‘valve_3way’] = (data[‘3way valve(On:DHW_Off:Space)’] == ‘OFF’ ? ‘Ambient’ : ‘DHW’) + ’ (’+ data[‘3way valve(On:DHW_Off:Space)’] +‘)’;
altherma[‘thermostat’] = data[‘Thermostat ON/OFF’];
if (data[‘Defrost Operation’] == ‘ON’) ops.push(‘defrost’);
if (data[‘Oil Return Operation’] == ‘ON’) ops.push(‘oil_return’);
if (data[‘Brine Flow Switch’] == ‘ON’) ops.push(‘brine’);
if (ops.length > 0) altherma[‘operations’] = ops.join(‘, ‘);
altherma[‘t_outdoor’] = data[‘R1T-Outdoor air temp.’];
altherma[‘t_acs’] = data[‘2nd Domestic hot water temperature’];
altherma[‘t_aanvoer’] = data[’[HPSU] Tv inflow Temp (R1T)’];
altherma[‘t_aanvoerBuh’] = data[‘[HPSU] Tvbh inflow Temp after Buffer/BUH (R2T)’];
altherma[‘t_retour’] = data[‘[HPSU] Tr return Temp (R4T)’];
altherma[‘t_tanktemp_dhw’] = data[‘DHW tank temp. (R5T)’];
altherma[‘t_setpoint’] = data[‘LW setpoint (main)’];
altherma[‘dhw_setpoint’] = data[‘DHW setpoint’];
altherma[‘t_heatingTarget’] = data[‘Boiler Heating Target Temp.’];
altherma[‘flowSensor’] = (data[‘Flow sensor (l/min)’] > 0 ? (data[‘Flow sensor (l/min)’] * 60).toFixed(0) : 0);
altherma[‘waterPump’] = data[‘Water pump operation’];
altherma[‘heat_delivered’] = (data[‘Flow sensor (l/min)’] * 0.06 * 1.16 * (altherma[‘t_aanvoerBuh’] - altherma[‘t_retour’]));
altherma[‘heat_delivered_alt’] = (data[‘Flow sensor (l/min)’] * 0.06 * 1.16 * (altherma[‘t_aanvoer’] - altherma[‘t_retour’]));

altherma[‘backupHeater’] = ‘OFF’;
if (data[‘BUH Step1’] == ‘ON’ || data[‘BUH Step2’] == ‘ON’) altherma[‘backupHeater’] = ‘ON’;
altherma[‘dt_h’] = data[‘Target delta T heating’];
altherma[‘dt_c’] = data[‘Target delta T cooling’];
altherma[‘cop’] = 0;
altherma[‘cop_alt’] = 0;
if (data[‘Operation Mode’] == ‘Heating’ && data[‘Freeze Protection’] == ‘OFF’) {
let c = (altherma[‘heat_delivered’] / (altherma[‘heat_pump_power’] / 1000));
if (c > 0) altherma[‘cop’] = parseFloat(c.toFixed(1));
let c_alt = (altherma[‘heat_delivered_alt’] / (altherma[‘heat_pump_power’] / 1000));
if (c_alt > 0) altherma[‘cop_alt’] = parseFloat(c_alt.toFixed(1));
}
altherma[‘heat_pump_power’] = parseFloat(altherma[‘heat_pump_power’].toFixed(1));
altherma[‘heat_pump_power_2’] = parseFloat(altherma[‘heat_pump_power_2’].toFixed(1));
if (altherma[‘mode’] == ‘Cooling’) {
altherma[‘heat_delivered’] = 0;
altherma[‘heat_delivered_alt’] = 0;
}
altherma[‘heat_delivered’] = parseFloat(altherma[‘heat_delivered’].toFixed(1));
altherma[‘heat_delivered_alt’] = parseFloat(altherma[‘heat_delivered_alt’].toFixed(1));
let operation = ‘-’;
if (altherma[‘defrost’] == ‘ON’) operation = ‘defrost’;
if (altherma[‘oil_return’] == ‘ON’) operation = ‘oil_return’;
if (altherma[‘brine’] == ‘ON’) operation = ‘brine’;

//await tag(‘esp_altherma_operation’, operation);
await tag(‘esp_altherma_mode’, altherma[‘mode’]);
await tag(‘esp_altherma_status’, altherma[‘status’]);
await tag(‘esp_altherma_cop’, altherma[‘cop’]);
await tag(‘esp_altherma_acs’, altherma[‘t_acs’]);
await tag(‘esp_altherma_heat_pump_power’, altherma[‘heat_pump_power’]);
await tag(‘esp_altherma_heat_pump_power_2’, altherma[‘heat_pump_power_2’]);
await tag(‘esp_altherma_aanvoer’, altherma[‘t_aanvoer’]);
await tag(‘esp_altherma_aanvoerBuh’, altherma[‘t_aanvoerBuh’]);
await tag(‘esp_altherma_retour’, altherma[‘t_retour’]);
await tag(‘esp_altherma_t_tanktemp_dhw’, altherma[‘t_tanktemp_dhw’]);
await tag(‘esp_altherma_dhw_setpoint’, altherma[‘dhw_setpoint’]);
await tag(‘esp_altherma_Target_delta_t_heating’, altherma[‘dt_h’]);
await tag(‘esp_altherma_2wegklep’, altherma[‘valve_2way’]);
await tag(‘esp_altherma_3wegklep’, altherma[‘valve_3way’]);
await tag(‘esp_altherma_thermostaat’, altherma[‘thermostat’]);
await tag(‘esp_altherma_buitentemp’, altherma[‘t_outdoor’]);
await tag(‘esp_altherma_LW_setpoint_main’, altherma[‘t_setpoint’]);
await tag(‘esp_altherma_Boiler_heating_target_temp’, altherma[‘t_heatingTarget’]);
await tag(‘esp_altherma_Flow_sensor_lmin’, altherma[‘flowSensor’]);
await tag(‘esp_altherma_Water_pump_operation’, altherma[‘waterPump’]);
await tag(‘esp_altherma_Heat_delivered’, altherma[‘heat_delivered’]);
await tag(‘esp_altherma_Heat_delivered_alt’, altherma[‘heat_delivered_alt’]);

altherma[‘heat_pump_power’] += ’ Wh’;
altherma[‘heat_pump_power_2’] += ’ Wh’;
altherma[‘heat_delivered’] += ’ Wh’;
altherma[‘heat_delivered_alt’] += ’ Wh’;
altherma[‘t_outdoor’] += ‘°’;
altherma[‘t_acs’] += ‘°’;
altherma[‘t_aanvoer’] += ‘°’;
altherma[‘t_aanvoerBuh’] += ‘°’;
altherma[‘t_retour’] += ‘°’;
altherma[‘t_tanktemp_dhw’] += ‘°’;
altherma[‘t_setpoint’] += ‘°’;
altherma[‘dhw_setpoint’] += ‘°’;
altherma[‘t_heatingTarget’] += ‘°’;
altherma[‘flowSensor’] += ’ l/h’;

await tag(‘esp_altherma’, JSON.stringify(altherma));

log(data);
log(altherma);

return true;

i think you have created a numeric tag and you try to set it with a string value. Add parseFloat() on tag with error…
If you don’t know which one it is, deactivate them all and activate them one at a time

Hi @diapolon ! Hope you are doing great.
Just found out my espaltherma isnt working anymore in combination with M5stickC PLUS
I must say it has been a while and i have absolutely no idea where to start looking how and where to fix the problem. Im no programmer..
Can you help me a bit here please?

my goal is that my heatpump works on the sun mainly, an not starts running too early in the morning.

FetchError: request to http://192.XXXXXXXXX /getData failed, reason: connect EHOSTUNREACH 192.XXXXXXXXX
at ClientRequest. (/app/node_modules/node-fetch/lib/index.js:1501:11)
at ClientRequest.emit (node:events:517:28)
at Socket.socketErrorListener (node:_http_client:501:9)
at Socket.emit (node:events:517:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
type: ‘system’,
errno: ‘EHOSTUNREACH’,
code: ‘EHOSTUNREACH’
}
FetchError: request to http://192.XXXXXXXX/getData failed, reason: connect EHOSTUNREACH 192.XXXXXXXXXXX
at ClientRequest. (/app/node_modules/node-fetch/lib/index.js:1501:11)
at ClientRequest.emit (node:events:517:28)
at Socket.socketErrorListener (node:_http_client:501:9)
at Socket.emit (node:events:517:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
type: ‘system’,
errno: ‘EHOSTUNREACH’,
code: ‘EHOSTUNREACH’
}
{}
{
mode: undefined,
status: ‘On’,
heat_pump_power: ‘NaN Wh’,
heat_pump_power_2: ‘NaN Wh’,
valve_2way: ‘Cool (undefined)’,
valve_3way: ‘DHW (undefined)’,
thermostat: undefined,
t_outdoor: ‘undefined°’,
t_acs: ‘undefined°’,
t_aanvoer: ‘undefined°’,
t_aanvoerBuh: ‘undefined°’,
t_retour: ‘undefined°’,
t_tanktemp_dhw: ‘undefined°’,
t_setpoint: ‘undefined°’,
dhw_setpoint: ‘undefined°’,
t_heatingTarget: ‘undefined°’,
flowSensor: ‘0 l/h’,
waterPump: undefined,
heat_delivered: ‘NaN Wh’,
heat_delivered_alt: ‘NaN Wh’,
backupHeater: ‘OFF’,
dt_h: undefined,
dt_c: undefined,
cop: 0,
cop_alt: 0
}

———————————————————
:white_check_mark: Script Success
:right_arrow_curving_left: Returned: true
{}
{
mode: undefined,
status: ‘On’,
heat_pump_power: ‘NaN Wh’,
heat_pump_power_2: ‘NaN Wh’,
valve_2way: ‘Cool (undefined)’,
valve_3way: ‘DHW (undefined)’,
thermostat: undefined,
t_outdoor: ‘undefined°’,
t_acs: ‘undefined°’,
t_aanvoer: ‘undefined°’,
t_aanvoerBuh: ‘undefined°’,
t_retour: ‘undefined°’,
t_tanktemp_dhw: ‘undefined°’,
t_setpoint: ‘undefined°’,
dhw_setpoint: ‘undefined°’,
t_heatingTarget: ‘undefined°’,
flowSensor: ‘0 l/h’,
waterPump: undefined,
heat_delivered: ‘NaN Wh’,
heat_delivered_alt: ‘NaN Wh’,
backupHeater: ‘OFF’,
dt_h: undefined,
dt_c: undefined,
cop: 0,
cop_alt: 0
}

———————————————————
:white_check_mark: Script Success
:right_arrow_curving_left: Returned: true

Hi, there seems to be no communication with M5stickC. Have you tried to turning the power off and on again?

Hi,
Thanks for replying!
Yes rebooted.
Also found out dat power is not sufficient from the rotex board so plugged in a 5v charger now.
Rebooted etc but same outcome..

Have you checked the lan connection? Maybe the m5stick ip is changed?

that works better! IP was changed indeed. Good to know.
Adjusted, now this:

Output
{}
{
mode: undefined,
status: ‘On’,
heat_pump_power: ‘NaN Wh’,
heat_pump_power_2: ‘NaN Wh’,
valve_2way: ‘Cool (undefined)’,
valve_3way: ‘DHW (undefined)’,
thermostat: undefined,
t_outdoor: ‘undefined°’,
t_acs: ‘undefined°’,
t_aanvoer: ‘undefined°’,
t_aanvoerBuh: ‘undefined°’,
t_retour: ‘undefined°’,
t_tanktemp_dhw: ‘undefined°’,
t_setpoint: ‘undefined°’,
dhw_setpoint: ‘undefined°’,
t_heatingTarget: ‘undefined°’,
flowSensor: ‘0 l/h’,
waterPump: undefined,
heat_delivered: ‘NaN Wh’,
heat_delivered_alt: ‘NaN Wh’,
backupHeater: ‘OFF’,
dt_h: undefined,
dt_c: undefined,
cop: 0,
cop_alt: 0
}

———————————————————
:white_check_mark: Script Success
:right_arrow_curving_left: Returned: true

Have redone the wiring with new wires, but outcome stays the same.
the stick runs and is connected with wifi. If placed the right ip address in the homey script and tested the script. Then i get that outcome as placed above..

Hi, if you open http://192.XXXXXXXXX /getData you obtain the data from espaltherma?

Hi, i dont know what this means.. what do i need to do?
http://192.xxx /getData fill in where?

(ill buy you a beer for all your help. Couple of beers too haha)

try to open the ip address of espaltherma and add at the end /getData. For example, if the ip is 192.168.1.232 open the url http://192.168.1.232/getData

via url the output is:

{
“Sensor Data Qty”: 4,
“INV compressor Qty”: 1,
“STD compressor Qty”: 0,
“Fan Data Qty”: 1,
“Expansion Valve Data Qty”: 1,
“4 Way Valve Data Qty”: 1,
“Crank Case Heater Qty”: 0,
“Solenoid valve Qty”: 0,
“O/U capacity (kW)”: 4,
“NextDataGrid”: “Conv 995 not avail.”,
“Operation Mode”: “Fan Only”,
“Thermostat ON/OFF”: “OFF”,
“Restart standby”: “OFF”,
“Startup Control”: “OFF”,
“Defrost Operation”: “OFF”,
“Pressure equalizing operation”: “ON”,
“Demand Signal”: “OFF”,
“Low noise control”: “OFF”,
“Error type”: “Normal”,
“Error Code”: " 0",
“Target Evap. Temp.”: 90,
“Target Cond. Temp.”: 0,
“Discharge Temp. Drop”: “OFF”,
“Discharge Temp. Protection Retry Qty”: “Conv 310 not avail.”,
“Comp. INV Current Drop”: “OFF”,
“Comp. INV Current Protection Retry Qty”: “Conv 311 not avail.”,
“HP Drop Control”: “OFF”,
“HP Protection Retry Qty”: “Conv 310 not avail.”,
“LP Drop Control”: “OFF”,
“LP Protection Retry Qty”: “Conv 311 not avail.”,
“Fin Temp. Drop Control”: “OFF”,
“Fin Temp. Protection Retry Qty”: “Conv 310 not avail.”,
“Other Drop Control”: “OFF”,
“R1T-Outdoor air temp.”: 12.5,
“O/U Heat Exch. Temp.”: 0,
“Discharge pipe temp.”: 74.5,
“Suction pipe temp.”: 0,
“Heat exchanger mid-temp.”: 14,
“Liquid pipe temp.(R6T)”: 0,
“Heat sink temp.”: 0,
“Pressure sensor”: 0,
“Pressure sensor(T)”: 11.1519,
“INV primary current (A)”: 0,
“INV secondary current (A)”: 0,
“Voltage (N-phase) (V)”: 33,
“Refrig. temp. evap. In”: 0,
“Refrig. temp. evap.Out”: 0,
“INV frequency (rps)”: 0,
“INV frequency 2 (rps)”: 0,
“STD Compressor 1”: “OFF”,
“STD Compressor 2”: “OFF”,
“Fan 1 (10 rpm)”: 0,
“Fan 2 (step)”: 0,
“Indoor Unit Address”: 0,
“I/U operation mode”: “Stop”,
“Freeze Protection”: “OFF”,
“Silent Mode”: “ON”,
“Error detailed code”: 0,
“I/U capacity code”: “Conv 219 not avail.”,
“DHW setpoint”: 46,
“LW setpoint (main)”: 24.6,
“Water flow switch”: “ON”,
“Thermal protector (Q1L) BUH”: “ON”,
“Thermal protector BSH”: “ON”,
“Benefit kWh rate power supply”: “OFF”,
“Solar input”: “OFF”,
“Bivalent Operation”: “OFF”,
“2way valve(On:Heat_Off:Cool)”: “OFF”,
“3way valve(On:DHW_Off:Space)”: “OFF”,
“BSH”: “OFF”,
“BPH”: “OFF”,
“Water pump operation”: “ON”,
“Solar pump operation”: “OFF”,
“Indoor Option Code”: 3,
“Data Enable/Disable”: “ON”,
“[HPSU] Tv inflow Temp (R1T)”: 23.9,
“[HPSU] Tvbh inflow Temp after Buffer/BUH (R2T)”: 24.1,
“Refrig. Temp. liquid side (R3T)”: 23.2,
“[HPSU] Tr return Temp (R4T)”: 24,
“DHW tank temp. (R5T)”: 52.7,
“Indoor ambient temp. (R1T)”: 0.4,
“Ext. indoor ambient sensor (R6T)”: 0,
“Reheat ON/OFF”: “OFF”,
“Storage ECO ON/OFF”: “OFF”,
“Storage comfort ON/OFF”: “OFF”,
“Powerful DHW Operation. ON/OFF”: “OFF”,
“Space heating Operation ON/OFF”: “OFF”,
“System OFF (ON:System off)”: “OFF”,
“LW setpoint (add)”: 25,
“RT setpoint”: 12,
“Add. Ext. RT Input Heat.”: “OFF”,
“Main RT Heating”: “OFF”,
“Pwr consumption limit 4”: “OFF”,
“Pwr consumption limit 3”: “OFF”,
“Pwr consumption limit 2”: “OFF”,
“Pwr consumption limit 1”: “OFF”,
“Tank preheat ON/OFF”: “OFF”,
“Circulation pump operation”: “OFF”,
“Alarm output”: “OFF”,
“Space H Operation output”: “OFF”,
“Flow sensor (l/min)”: 13,
“Water pressure”: 0,
“Water pump signal (0:max-100:stop)”: 44,
“[Future] 3 way Valve Mixing 1”: 0,
“[Future] 3 way Valve Mixing 2”: 0,
“Refrigerant pressure sensor”: 10.7,
“Boiler Operation Demand”: “OFF”,
“Boiler DHW Demand”: “OFF”,
“Bypass Valve Output”: “ON”,
“BE_COP”: 0,
“Boiler Heating Target Temp.”: 60,
“Mixed water temp.”: 0,
“Target delta T heating”: 5
}

that seems to be working!..
the script in homey is

¨const b_ip = ‘192.XXXXXXX’;
const b_baseurl = ‘http://’+ b_ip + ‘/getData’;

function toFixed(num) {
return Math.trunc((num * 100) / 100);
}

data = {};

try {
const res = await fetch(b_baseurl);
if (res.ok) data = await res.json();
} catch (err) {
log(err);
}

let ops = ;

altherma = {};
switch(data[‘Operation Mode’]) {
case ‘Fan Only’:
altherma[‘mode’] = ‘Fan Only’;
break;
case ‘Heating’:
altherma[‘mode’] = ‘Heating’;
break;
case ‘Cooling’:
altherma[‘mode’] = ‘Cooling’;
break;
default:
altherma[‘mode’] = data[‘Operation Mode’];
}

switch(data[‘I/U operation mode’]) {
case ‘DHW’:
altherma[‘status’] = ‘On’;
altherma[‘mode’] = ‘DHW’;
break;
case ‘Stop’:
altherma[‘status’] = ‘-’;
break;
default:
altherma[‘status’] = ‘On’;
}
//if (altherma[‘status’] == ‘Stop’) altherma[‘status’] = ‘Off’;

let voltage = Math.min(230, data[‘Voltage (N-phase) (V)’]);

altherma[‘heat_pump_power’] = (data[‘INV primary current (A)’] * voltage);
altherma[‘heat_pump_power_2’] = (data[‘INV secondary current (A)’] * voltage);
altherma[‘valve_2way’] = (data[‘2way valve(On:Heat_Off:Cool)’] == ‘ON’ ? ‘Heat’ : ‘Cool’) + ’ (‘+ data[‘2way valve(On:Heat_Off:Cool)’] +’)‘;
altherma[‘valve_3way’] = (data[‘3way valve(On:DHW_Off:Space)’] == ‘OFF’ ? ‘Ambient’ : ‘DHW’) + ’ (’+ data[‘3way valve(On:DHW_Off:Space)’] +‘)’;
altherma[‘thermostat’] = data[‘Thermostat ON/OFF’];
if (data[‘Defrost Operation’] == ‘ON’) ops.push(‘defrost’);
if (data[‘Oil Return Operation’] == ‘ON’) ops.push(‘oil_return’);
if (data[‘Brine Flow Switch’] == ‘ON’) ops.push(‘brine’);
if (ops.length > 0) altherma[‘operations’] = ops.join(‘, ‘);
altherma[‘t_outdoor’] = data[‘R1T-Outdoor air temp.’];
altherma[‘t_acs’] = data[‘2nd Domestic hot water temperature’];
altherma[‘t_aanvoer’] = data[’[HPSU] Tv inflow Temp (R1T)’];
altherma[‘t_aanvoerBuh’] = data[‘[HPSU] Tvbh inflow Temp after Buffer/BUH (R2T)’];
altherma[‘t_retour’] = data[‘[HPSU] Tr return Temp (R4T)’];
altherma[‘t_tanktemp_dhw’] = data[‘DHW tank temp. (R5T)’];
altherma[‘t_setpoint’] = data[‘LW setpoint (main)’];
altherma[‘dhw_setpoint’] = data[‘DHW setpoint’];
altherma[‘t_heatingTarget’] = data[‘Boiler Heating Target Temp.’];
altherma[‘flowSensor’] = (data[‘Flow sensor (l/min)’] > 0 ? (data[‘Flow sensor (l/min)’] * 60).toFixed(0) : 0);
altherma[‘waterPump’] = data[‘Water pump operation’];
altherma[‘heat_delivered’] = (data[‘Flow sensor (l/min)’] * 0.06 * 1.16 * (altherma[‘t_aanvoerBuh’] - altherma[‘t_retour’]));
altherma[‘heat_delivered_alt’] = (data[‘Flow sensor (l/min)’] * 0.06 * 1.16 * (altherma[‘t_aanvoer’] - altherma[‘t_retour’]));

altherma[‘backupHeater’] = ‘OFF’;
if (data[‘BUH Step1’] == ‘ON’ || data[‘BUH Step2’] == ‘ON’) altherma[‘backupHeater’] = ‘ON’;
altherma[‘dt_h’] = data[‘Target delta T heating’];
altherma[‘dt_c’] = data[‘Target delta T cooling’];
altherma[‘cop’] = 0;
altherma[‘cop_alt’] = 0;
if (data[‘Operation Mode’] == ‘Heating’ && data[‘Freeze Protection’] == ‘OFF’) {
let c = (altherma[‘heat_delivered’] / (altherma[‘heat_pump_power’] / 1000));
if (c > 0) altherma[‘cop’] = parseFloat(c.toFixed(1));
let c_alt = (altherma[‘heat_delivered_alt’] / (altherma[‘heat_pump_power’] / 1000));
if (c_alt > 0) altherma[‘cop_alt’] = parseFloat(c_alt.toFixed(1));
}
altherma[‘heat_pump_power’] = parseFloat(altherma[‘heat_pump_power’].toFixed(1));
altherma[‘heat_pump_power_2’] = parseFloat(altherma[‘heat_pump_power_2’].toFixed(1));
if (altherma[‘mode’] == ‘Cooling’) {
altherma[‘heat_delivered’] = 0;
altherma[‘heat_delivered_alt’] = 0;
}
altherma[‘heat_delivered’] = parseFloat(altherma[‘heat_delivered’].toFixed(1));
altherma[‘heat_delivered_alt’] = parseFloat(altherma[‘heat_delivered_alt’].toFixed(1));
let operation = ‘-’;
if (altherma[‘defrost’] == ‘ON’) operation = ‘defrost’;
if (altherma[‘oil_return’] == ‘ON’) operation = ‘oil_return’;
if (altherma[‘brine’] == ‘ON’) operation = ‘brine’;

//await tag(‘esp_altherma_operation’, operation);
await tag(‘esp_altherma_mode’, altherma[‘mode’]);
await tag(‘esp_altherma_status’, altherma[‘status’]);
await tag(‘esp_altherma_cop’, altherma[‘cop’]);
await tag(‘esp_altherma_acs’, altherma[‘t_acs’]);
await tag(‘esp_altherma_heat_pump_power’, altherma[‘heat_pump_power’]);
await tag(‘esp_altherma_heat_pump_power_2’, altherma[‘heat_pump_power_2’]);
await tag(‘esp_altherma_aanvoer’, altherma[‘t_aanvoer’]);
await tag(‘esp_altherma_aanvoerBuh’, altherma[‘t_aanvoerBuh’]);
await tag(‘esp_altherma_retour’, altherma[‘t_retour’]);
await tag(‘esp_altherma_t_tanktemp_dhw’, altherma[‘t_tanktemp_dhw’]);
await tag(‘esp_altherma_dhw_setpoint’, altherma[‘dhw_setpoint’]);
await tag(‘esp_altherma_Target_delta_t_heating’, altherma[‘dt_h’]);
await tag(‘esp_altherma_2wegklep’, altherma[‘valve_2way’]);
await tag(‘esp_altherma_3wegklep’, altherma[‘valve_3way’]);
await tag(‘esp_altherma_thermostaat’, altherma[‘thermostat’]);
await tag(‘esp_altherma_buitentemp’, altherma[‘t_outdoor’]);
await tag(‘esp_altherma_LW_setpoint_main’, altherma[‘t_setpoint’]);
await tag(‘esp_altherma_Boiler_heating_target_temp’, altherma[‘t_heatingTarget’]);
await tag(‘esp_altherma_Flow_sensor_lmin’, altherma[‘flowSensor’]);
await tag(‘esp_altherma_Water_pump_operation’, altherma[‘waterPump’]);
await tag(‘esp_altherma_Heat_delivered’, altherma[‘heat_delivered’]);
await tag(‘esp_altherma_Heat_delivered_alt’, altherma[‘heat_delivered_alt’]);

altherma[‘heat_pump_power’] += ’ Wh’;
altherma[‘heat_pump_power_2’] += ’ Wh’;
altherma[‘heat_delivered’] += ’ Wh’;
altherma[‘heat_delivered_alt’] += ’ Wh’;
altherma[‘t_outdoor’] += ‘°’;
altherma[‘t_acs’] += ‘°’;
altherma[‘t_aanvoer’] += ‘°’;
altherma[‘t_aanvoerBuh’] += ‘°’;
altherma[‘t_retour’] += ‘°’;
altherma[‘t_tanktemp_dhw’] += ‘°’;
altherma[‘t_setpoint’] += ‘°’;
altherma[‘dhw_setpoint’] += ‘°’;
altherma[‘t_heatingTarget’] += ‘°’;
altherma[‘flowSensor’] += ’ l/h’;

await tag(‘esp_altherma’, JSON.stringify(altherma));

log(data);
log(altherma);

return true;

and the output is now

———————————————————
:cross_mark: Script Error
:warning: Error: Invalid Type. Got: string. Expected: Number
at FlowToken.setValue (/node_modules/@athombv/homey-apps-sdk-v3/lib/FlowToken.js:60:13)
at HomeyScriptApp.setToken (/app/app.js:247:38)
at tag (/app/app.js:327:38)
at esphome.js:116:7
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async HomeyScriptApp.runScript (/app/app.js:364:22)
at async Object.runScript (/app/api.js:30:22)