1
English corner / Re: How to coordinate multiple phones?
« Letzter Beitrag von Admin am 18.08.2024, 13:57:13 »Yes, Fhem is for a bigger project.
What you did with Node Red is great.
What you did with Node Red is great.
const phone = msg.req.query.phone;
const fence = msg.req.query.fence;
if (phone && fence) {
const isEntering = fence.toLowerCase() === 'entering';
const isExiting = fence.toLowerCase() === 'exiting';
if (isEntering || isExiting) {
const atHome = isEntering;
flow.set(phone, atHome);
msg.payload = {
status: 'success',
message: `${phone} is ${fence} the geofence`,
value: atHome
};
} else {
msg.payload = {
status: 'error',
message: 'Invalid fence value. Must be "entering" or "exiting".'
};
}
} else {
msg.payload = {
status: 'error',
message: 'Missing phone or fence parameter'
};
}
return msg;
http response is just Status Code: 200function checkHomeStatusAndPrepareURL() {
const jillAtHome = flow.get('Jill') || false;
const peteAtHome = flow.get('Pete') || false;
let schedule;
if (!jillAtHome && !peteAtHome) {
schedule = 'Away';
} else {
schedule = 'Day_Night';
}
const baseUrl = 'http://10.123.123.123:81/admin';
const params = `schedule=${encodeURIComponent(schedule)}&lock=2&user=USERNAME&pw=PASSWORD3`;
msg.url = `${baseUrl}?${params}`;
return msg;
}
return checkHomeStatusAndPrepareURL();