I've been testing for hours now and just cannot seem to find a solution. I'm missing something but just do not get it. Please assist (I'm a beginner) with Node-red.
I want to calculate the total costs, so add up of all 4 values:
const globalHomeAssistant = global.get('homeassistant');
var dag = globalHomeAssistant.homeAssistant.states["sensor.stroomverbruik_maandelijks_dag"].state;
var nacht = globalHomeAssistant.homeAssistant.states["sensor.stroomverbruik_maandelijks_nacht"].state;
var gas = globalHomeAssistant.homeAssistant.states["sensor.monthly_gas_consumption"].state;
var water = globalHomeAssistant.homeAssistant.states["sensor.monthly_water_consumption"].state;
var water1 = Number(water * 0.604 + 46.04).toFixed(2); --this has value 46.33
var stroom1 = Number(dag * 0.14551).toFixed(2); --this has value 2.44
var stroom2 = Number(nacht * 0.13343).toFixed(2); --this has value 6.53
var gas1 = Number(gas * 0.75516).toFixed(2); --this has value 1.32
msg.payload_totale_kosten = (stroom1+stroom2+gas1+water1);
return msg;
but this gives me a result of: 2.446.531.3246.33
it is not a sum but just all number next to each other. I've tried many things, but none seem to work.