The IOAF (Internet of Air Fresheners)!

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
piedro
Posts: 6
Joined: Wednesday 07 November 2018 11:09
Target OS: Linux
Domoticz version:
Contact:

The IOAF (Internet of Air Fresheners)!

Post by piedro »

Those Airwick things do their refresh-cycle based on a timer, so it spits out perfume when not needed (when not at home, in your face in the middle of the night, etc). Obviously Airwick wants you to buy their containers. So let's lobotomize their evil invention and control it through a Sonoff SV, with Domoticz as its master brain.

Our volunteer:
Image

And its evil brain:
Image


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
Hardware config
  • Attach the Airwick to the Sonoff SV 5V relay output
  • Attach 5V power to the Sonoff SV and the relay pass thru circuit
Now a much better looking Airwick, eager to be under your control:
Image


Software Config
In the Tasmota console through the Sonoff SV webpage enter:

Code: Select all

 Blinkcount 1
and

Code: Select all

Blinktime 4
to prepare a 0.4 sec burst of power, instead of normal on/off operation. Subsequently the command in the console

Code: Select all

power 3 
or from MQTT/Node red:

Code: Select all

cmnd/sonoffsv/power
with

Code: Select all

msg.payload=3
will arrange a short power-on refreshment; assuming mqtt topic changed to

Code: Select all

sonoffsv

Prepare Node Red to convert a Domoticz MQTT message (assuming switch id in domoticz is 13

Image

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":""}]
In Domoticz make a virtual switch with a ‘Push on Button’ to control the freshener by hand
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
}
Feel refreshed!
jake
Posts: 744
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: The IOAF (Internet of Air Fresheners)!

Post by jake »

Thanks for this how-to and the way you described it!
I still wonder about one thing, actually 2. Your script is not preventing a 'shot in the face', nor usage during your holidays. ;)

I guess this is different for everybody, with the sample script people can adapt it to their wishes.
piedro
Posts: 6
Joined: Wednesday 07 November 2018 11:09
Target OS: Linux
Domoticz version:
Contact:

Re: The IOAF (Internet of Air Fresheners)!

Post by piedro »

You are absolutely right about the shot in the face problem. You would need a PIR sensor for this, in the meantime seriously jeopardizing the WAF (Wife Acceptance Factor).

I do check for presence (based on Wifi association of smartphones), which means that it should not spray in our absence. For logistical reasons, I did not have the opportunity to test this :|
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest