Hi @kilasat,
hier die beiden Javascripte. Als erstes die Datenpunkte hinzufügen und das Script einmal ausführen (1. Script), danach das 2. Script aktivieren und laufen lassen. Achso, natürlich noch die Werte (in beiden Scripts) anpassen, ich habe 2 von den Dingern laufen und da kannste alles für den 2. rausschmeißen.
In der Json ist meine Sicht mit dem Gerät, die kannste importieren und auch auf deine Datenpunkte anpassen.
/* Setze neue Datenpunkte für
* - Wartungspunkt setzen pro Vacuum
* - Weitere Zonen einrichten, über script, da wenn der Adapter mal nicht mehr funktioniert die Werte nicht erneut ermittelt werden müssen
* - Warteschlange erzeugen, Standard reichte mir nicht
* -
*/
//Settings
//Anzahl der Vacuum
var countVacuum = ['mihome-vacuum.0', 'mihome-vacuum.1'];
var channelRooms = '.rooms';
var servicePoints = ['22250,32300','27950,25450']
var addRrooms = [
{
'room' : ['Zone1','Zone2','Zone3'],
'datenpunkt' : [[25235,29306,27535,30356],[23502,24895,25102,25995],[27763,30413,29163,33013]]
}
]
//Channel für alle Vacuum unter userdata anlegen
setObject("0_userdata.0.vacuums", {
common: {
name: "Vacuums Zusatzpunkte"
},
type: "channel"
});
//Datenpunkte für ServicePoint und CleaningQueue pro Vacuum anlegen
for (var v = 0; v < countVacuum.length; v++) {
//Koordinaten des jeweiligen ServicPoints speichern
if (servicePoints[v] != null){
createState("0_userdata.0." + countVacuum[v] + ".servicepoint", servicePoints[v], false, {
name: "servicepoint",
desc: "coordinates of servicepoint",
type: "number",
role: "value",
unit: "",
read: false,
write: false
});
}
//Eine erweiterte CleaningQueue anlegen, in der dann Zone und Segment herausgefiltert wird und nur der Name steht
createState("0_userdata.0." + countVacuum[v] + ".cleaningQueue", "", false, {
name: "cleaning queue",
desc: "cleaning queue",
type: "object",
role: "info",
unit: "",
read: true,
write: true
});
//Für die Ermittlung und anzeige des aktuellen Raumes, der gereinigt wird
createState("0_userdata.0." + countVacuum[v] + ".currentRoom", "", false, {
name: "current cleaning",
desc: "current cleaning room or zone",
type: "object",
role: "info",
unit: "",
read: true,
write: true
});
//Datenpunkt für den Button Servicepoint
createState("0_userdata.0." + countVacuum[v] + ".goToService", false, false, {
name: "goToService",
desc: "going to ServicePointcleaning queue",
type: "boolean",
role: "button",
unit: "",
read: false,
write: true
});
//Weitere Zonen anlegen
if(addRrooms[v]!=null){
for (var i = 0; i < addRrooms[v]['room'].length; i++) {
setState(countVacuum[v] + channelRooms + ".addRoom", addRrooms[v]['datenpunkt'][i]);
var roomchannel = addRrooms[v]['datenpunkt'][i].toString();
roomchannel = roomchannel.replace("[", "");
roomchannel = roomchannel.replace("]", "");
roomchannel = roomchannel.split(",").join("_"); /*replaceAll(",", "_");*/
setState(countVacuum[v] + channelRooms + "." + roomchannel + ".roomFanPower", 103);
setState(countVacuum[v] + channelRooms + "." + roomchannel + ".roomWaterBoxMode", 202);
}
}
}
//////////////////// Vacuum 1 //////////////////////
//Die beim nach Hause schicken die Queue leeren
on({id: 'mihome-vacuum.0.control.home', val: true}, function() {
setState('mihome-vacuum.0.control.clearQueue', true);
});
//Die Queue der aktuellen Reinigung löschen wenn Vacuum in der Ladestation ist
on({id: 'mihome-vacuum.0.info.state'/*Vacuum state*/, val: 8}, function() {
setState('0_userdata.0.mihome-vacuum.0.currentRoom', '');
});
//Den aktuell zu reinigenden Raum ermitteln
on({id: 'mihome-vacuum.0.rooms.106001012191.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.0.currentRoom', getObject('mihome-vacuum.0.rooms.106001012191').common.name);
});
on({id: 'mihome-vacuum.0.rooms.106001012206.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.0.currentRoom', getObject('mihome-vacuum.0.rooms.106001012206').common.name);
});
on({id: 'mihome-vacuum.0.rooms.106001012207.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.0.currentRoom', getObject('mihome-vacuum.0.rooms.106001012207').common.name);
});
on({id: 'mihome-vacuum.0.rooms.106001012208.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.0.currentRoom', getObject('mihome-vacuum.0.rooms.106001012208').common.name);
});
on({id: 'mihome-vacuum.0.rooms.106001012209.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.0.currentRoom', getObject('mihome-vacuum.0.rooms.106001012209').common.name);
});
on({id: 'mihome-vacuum.0.rooms.106001012210.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.0.currentRoom', getObject('mihome-vacuum.0.rooms.106001012210').common.name);
});
on({id: 'mihome-vacuum.0.rooms.manual_23502_24895_25102_25995.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.0.currentRoom', getObject('mihome-vacuum.0.rooms.manual_23502_24895_25102_25995').common.name);
});
on({id: 'mihome-vacuum.0.rooms.manual_25235_29306_27535_30356.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.0.currentRoom', getObject('mihome-vacuum.0.rooms.manual_25235_29306_27535_30356').common.name);
});
on({id: 'mihome-vacuum.0.rooms.manual_27763_30413_29163_33013.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.0.currentRoom', getObject('mihome-vacuum.0.rooms.manual_27763_30413_29163_33013').common.name);
});
//Die Standard CleaningQueue anpassen
on({id: 'mihome-vacuum.0.info.queue', change: 'any'}, function (obj) {
var queue = obj.state.val
var tmpCleaningQueue = "Next: ";
if (queue.length != 0) {
log(queue.length);
queue.reverse();
for (var i = 0; i < queue.length; i++){
tmpCleaningQueue += queue[i].replace("segment", "").replace("zone", "");
if(i+1<queue.length){
tmpCleaningQueue+= ",";
}
}
}
else {
tmpCleaningQueue = "";
}
setState('0_userdata.0.mihome-vacuum.0.cleaningQueue'/*cleaning queue*/, tmpCleaningQueue)
});
//Auf den Button goToServicepoint reagieren
on({id: '0_userdata.0.mihome-vacuum.0.goToService'/*goToService*/, val: true}, function (obj) {
var servicepoint = getState('0_userdata.0.mihome-vacuum.0.servicepoint'/*map index*/).val;
setState('mihome-vacuum.0.control.goTo'/*Go to point*/,servicepoint);
});
//////////////////// Vacuum 2 //////////////////////
//Die beim nach Hause schicken die Queue leeren
on({id: 'mihome-vacuum.1.control.home', val: true}, function() {
setState('mihome-vacuum.1.control.clearQueue', true);
});
//Die Queue der aktuellen Reinigung löschen wenn Vacuum in der Ladestation ist
on({id: 'mihome-vacuum.1.info.state'/*Vacuum state*/, val: 8}, function() {
setState('0_userdata.0.mihome-vacuum.1.currentRoom', '');
});
//Den aktuell zu reinigenden Raum ermitteln
on({id: 'mihome-vacuum.1.rooms.106001012200.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.1.currentRoom', getObject('mihome-vacuum.1.rooms.106001012200').common.name);
});
on({id: 'mihome-vacuum.1.rooms.106001012201.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.1.currentRoom', getObject('mihome-vacuum.1.rooms.106001012201').common.name);
});
on({id: 'mihome-vacuum.1.rooms.106001012202.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.1.currentRoom', getObject('mihome-vacuum.1.rooms.106001012202').common.name);
});
on({id: 'mihome-vacuum.1.rooms.106001012203.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.1.currentRoom', getObject('mihome-vacuum.1.rooms.106001012203').common.name);
});
on({id: 'mihome-vacuum.1.rooms.106001012205.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.1.currentRoom', getObject('mihome-vacuum.1.rooms.106001012205').common.name);
});
on({id: 'mihome-vacuum.1.rooms.106001012607.state'/*info*/, val: "clean Room"}, function() {
setState('0_userdata.0.mihome-vacuum.1.currentRoom', getObject('mihome-vacuum.1.rooms.106001012607').common.name);
});
//Die Standard CleaningQueue anpassen
on({id: 'mihome-vacuum.1.info.queue', change: 'any'}, function (obj) {
var queue = obj.state.val
var tmpCleaningQueue = "Next ";
if (queue.length != 0) {
for (var i = 0; i < queue.length; i++){
tmpCleaningQueue += queue[i].replace("segment", "").replace("zone", "");
if(i+1<queue.length){
tmpCleaningQueue+= ",";
}
}
}
else {
tmpCleaningQueue = "";
}
setState('0_userdata.0.mihome-vacuum.1.cleaningQueue'/*cleaning queue*/, tmpCleaningQueue)
});
//Auf den Button goToServicepoint reagieren
on({id: '0_userdata.0.mihome-vacuum.1.goToService'/*goToService*/, val: true}, function (obj) {
var servicepoint = getState('0_userdata.0.mihome-vacuum.1.servicepoint'/*map index*/).val;
setState('mihome-vacuum.1.control.goTo'/*Go to point*/,servicepoint);
});
2021-08-20_iqontrol_0_selected_views.json