Ich habe noch 4 Platinen V1 da und einen Satz mit 6 poligen JST-SM. Wenn Interesse besteht bitte PN.
NEWS
Latest posts made by Chris685
-
RE: Lay-Z-Spa Wifi Control
-
RE: Lay-Z-Spa Wifi Control
Update um die Außentemperatur (Umgebungstemperatur) über ioBroker zur Berechnung der virtuellen Temperatur einzubinden.
const Messages = { "CONTENT": "STATES", "LCK": 0, "PWR": 0, "UNT": 1, "AIR": 0, "GRN": 0, "RED": 0, "FLT": 0, "TGT": 22, "TMP": 13, "CH1": 32, "CH2": 49, "CH3": 51, "HJT": 0, "BRT": 7, "AMBC": 22 } const ID = '0_userdata.0.LazySpa'; const MQTTINSTANCE = 0; const debug = true; /* { "CONTENT": "TIMES", "TIME": 1650746370, "CLTIME": 1644734714, "FTIME": 1644734719, "UPTIME": 41660, "PUMPTIME": 50, "HEATINGTIME": 24, "AIRTIME": 512, "JETTIME": 4294966, "COST": 0, "FINT": 4294967295, "CLINT": 4294967295, "KWH": null, "TTTT": -74677 } */ const STATES=[ { _id: 'LCK', type: 'state', common: { name: 'lock', type: 'boolean', role: 'switch', read: true, write: false, desc: 'Lazy spa lock' }, native: {} }, { _id: 'PWR', type: 'state', common: { name: 'power', type: 'boolean', role: 'switch.power', read: true, write: true, desc: 'Lazy spa power' }, native: {} }, { _id: 'UNT', type: 'state', common: { name: 'unit', type: 'number', role: 'value', read: true, write: true, max: 1, desc: 'Lazy spa unit', states: { 0: 'Farenheit', 1: 'Celsius' } }, native: {} }, { _id: 'AIR', type: 'state', common: { name: 'bubbles', type: 'boolean', role: 'switch', read: true, write: true, desc: 'Lazy spa bubbles state' }, native: {} }, { _id: 'GRN', type: 'state', common: { name: 'Heating green', type: 'boolean', role: 'switch', read: true, write: false, desc: 'reached target temp.' }, native: {} }, { _id: 'RED', type: 'state', common: { name: 'Heating red', type: 'boolean', role: 'switch', read: true, write: false, desc: 'not reached target temp.' }, native: {} }, { _id: 'FLT', type: 'state', common: { name: 'pump', type: 'boolean', role: 'switch', read: true, write: true, desc: 'pump state' }, native: {} }, { _id: 'HEATER', type: 'state', common: { name: 'heater', type: 'boolean', role: 'switch', read: true, write: true, desc: 'heater state' }, native: {} }, { _id: 'TGT', type: 'state', common: { name: 'target temp', type: 'number', role: 'level.temperature', min: 20, max: 40, steps: 1, read: true, write: true, desc: 'taget temp.' }, native: {} }, { _id: 'TMP', type: 'state', common: { name: 'temp', type: 'number', role: 'value.temperature', read: true, write: false, unit: '°C', desc: 'temp.' }, native: {} }, { _id: 'VTM', type: 'state', common: { name: 'temp', type: 'number', role: 'value.temperature', read: true, write: false, unit: '°C', desc: 'vtemp.' }, native: {} }, { _id: 'AMBC', type: 'state', common: { name: 'ambient temp', type: 'number', role: 'value.temperature', read: false, write: true, desc: 'Ambienttemp.' }, native: {} }, ] init(); async function stateChange(obj){ let id = obj.id let state = id.split('.').pop() let value = obj.state.val log('change Unit' + state) switch (state) { case 'UNT': setStateAsync('mqtt.'+ MQTTINSTANCE+'.layzspa.command','{"CMD":1,"VALUE":'+ value +',"XTIME":0,"INTERVAL":0}') log('change Unit') break; case 'TGT': setStateAsync('mqtt.'+ MQTTINSTANCE+'.layzspa.command','{"CMD":0,"VALUE":'+ value +',"XTIME":0,"INTERVAL":0}') log('change target temp. to '+ value); break; case 'AIR': value = value ? 1: 0 ; setStateAsync('mqtt.'+ MQTTINSTANCE+'.layzspa.command','{"CMD":2,"VALUE":'+ value +',"XTIME":0,"INTERVAL":0}') log('set bubbles to '+ value); break; case 'HEATER': value = value ? 1: 0 ; setStateAsync('mqtt.'+ MQTTINSTANCE+'.layzspa.command','{"CMD":3,"VALUE":'+ value +',"XTIME":0,"INTERVAL":0}') log('set Heater to '+ value); break; case 'FLT': value = value ? 1: 0 ; setStateAsync('mqtt.'+ MQTTINSTANCE+'.layzspa.command','{"CMD":4,"VALUE":'+ value +',"XTIME":0,"INTERVAL":0}') log('set pump to '+ value); break; case 'AMBC': setStateAsync('mqtt.'+ MQTTINSTANCE+'.layzspa.command','{"CMD":14,"VALUE":'+ value +',"XTIME":0,"INTERVAL":0}') log('change ambient temp. to '+ value); break; default: // Anweisungen werden ausgeführt, // falls keine der case-Klauseln mit expression übereinstimmt break; } } async function init(){ await asyncForEach(STATES, async (obj, index) => { let id = ID +'.'+ obj._id if (!existsState(id)) { log('create state '+ id) await createStateAsync(id, obj.common) } else { log('skip state '+ id) } //set subscription if(obj.common.write){ on({id: id, change:"any"} , function(obj) { if(!obj.state.ack){ log('change state! '+ JSON.stringify(obj)) stateChange(obj) } }); } }); log('init done!') } async function setLazyStates(obj){ try{ let states = JSON.parse(obj) for (const [key, value] of Object.entries(states)) { let statevalue = value const found = STATES.find(state => state._id === key); if(found){ if (found.common.type === 'boolean'){ statevalue = value === 1 } await setStateAsync(ID +'.'+ key,statevalue,true) } } //set heater state await setStateAsync(ID +'.HEATER',(states.GRN || states.RED) === 1,true) } catch(e){ console.log('Error in setting State '+ e) } } async function asyncForEach(array, callback) { for (let index = 0; index < array.length; index++) { await callback(array[index], index, array); } } function log (msg){ if(debug) console.log (msg) } on({id:'mqtt.'+ MQTTINSTANCE+'.layzspa.message', change:"ne"} , function(obj) { log('Lazyspa reached message! '+ JSON.stringify(obj.state)) setLazyStates(obj.state.val) });
Die Variable AMBC update ich bei Änderung der Außentemperatur. Ich lese die Außentemperatur über Netatmo ein.