Our volunteer:

And its evil brain:

Hardware Components
- Lobotimised Airwick with only motor-leads hanging out
- Either an USB Powerbank without low-power shut-off (most powerbanks are not usable!)
or a fancy self-mode charge circuit, with an 3.7v battery of a powerbank and buck voltage converter circuit to 5V
or an adapter for the more faint of heart
- Sonoff SV (prepared for isolated mode by removing resistors; isolated mode works better than feed-through as the Airwick motor needs quite some power and the SV circuitry can not handle this)
Refreshingly, that seems to be all!
Software Components
- Tasmotised Sonoff SV for its MQTT capability, among others
- Node Red to convert the MQTT command from domoticz towards the Sonoff SV
- Domoticz with all the intelligent stuff
- Mosquito as an MQTT broker
- Attach the Airwick to the Sonoff SV 5V relay output
- Attach 5V power to the Sonoff SV and the relay pass thru circuit

Software Config
In the Tasmota console through the Sonoff SV webpage enter:
Code: Select all
Blinkcount 1
Code: Select all
Blinktime 4
Code: Select all
power 3
Code: Select all
cmnd/sonoffsv/power
Code: Select all
msg.payload=3
Code: Select all
sonoffsv
Prepare Node Red to convert a Domoticz MQTT message (assuming switch id in domoticz is 13

Code: Select all
[{"id":"4e57340c.a15bbc","type":"mqtt out","z":"c3a3974.b558268","name":"","topic":"cmnd/sonoffsv/power","qos":"","retain":"","broker":"362f1eb8.2dcf02","x":894,"y":362,"wires":[]},{"id":"82b0d672.cf81f8","type":"inject","z":"c3a3974.b558268","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":300,"y":255,"wires":[["ba6e104b.89fef"]]},{"id":"ba6e104b.89fef","type":"function","z":"c3a3974.b558268","name":"power","func":"msg.payload = {};\nmsg.payload = 3;\nreturn msg;","outputs":1,"noerr":0,"x":627,"y":365,"wires":[["4e57340c.a15bbc"]]},{"id":"58f4701.3eb859","type":"mqtt in","z":"c3a3974.b558268","name":"","topic":"domoticz/out","qos":"2","broker":"362f1eb8.2dcf02","x":144,"y":461,"wires":[["2fa99da8.e94102"]]},{"id":"2fa99da8.e94102","type":"json","z":"c3a3974.b558268","name":"","pretty":false,"x":299,"y":459,"wires":[["8a4ef0e8.90563"]]},{"id":"8a4ef0e8.90563","type":"switch","z":"c3a3974.b558268","name":"","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"13","vt":"num"}],"checkall":"true","outputs":1,"x":461,"y":468,"wires":[["bb7bfb6a.a7fe18"]]},{"id":"bb7bfb6a.a7fe18","type":"switch","z":"c3a3974.b558268","name":"","property":"payload.nvalue","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","outputs":1,"x":600,"y":472,"wires":[["ba6e104b.89fef"]]},{"id":"362f1eb8.2dcf02","type":"mqtt-broker","z":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
And make Domoticz do some intelligent stuff in an event script based on presence.
Code: Select all
local myLightIDX = 13 -- Your light's idx
local myPresIDX = 4 -- Your presence idx
return {
on = {
timer = {
'every 15 minutes at daytime',
'every 60 minutes at nighttime'
}
},
execute = function(dz, timer)
myLight = dz.devices(myLightIDX)
myPres= dz.devices(myPresIDX)
if (myPres.state=='On')
then
myLight.switchOff().checkFirst().afterSec(1).silent()
myLight.switchOn().checkFirst().forSec(1).silent()
end
end
}