← Back to projects
PROJECT / 09Personal lab
Arduino & Raspberry Pi home automation
Lighting and ventilation controlled by sensors and simple rules.
WEB PROTOTYPE
Simulate temperature, presence and ambient light. Outputs follow rules and a sample MQTT message. No devices are connected.
View concept code
export function homeState({ temperature, threshold, lux, presence }) {
if (
![temperature, threshold, lux].every(Number.isFinite) ||
temperature < 10 ||
temperature > 40 ||
threshold < 20 ||
threshold > 35 ||
lux < 0 ||
lux > 1000 ||
typeof presence !== 'boolean'
)
throw Error('Invalid sensor data');
return {
temperature,
lux,
presence,
light: presence && lux < 300,
fan: temperature >= threshold,
simulated: true,
};
}