The MUSH-MACHINE: Rule triggering on mqtt values, storing and displaying it


(Rob) #22

Why can´t I show the PPM value properly in the frontend?


(Vincent Regaud) #23

Remove the label parameter in the sitemap.
It is already defined in the item


(Rob) #24

Yes and no!
Yes: i removed the label in the sitemap as you´re right - not needed
No: That wasn´t the problem: I did not realize that the value PPM hast 2 digits. corrected that and it worked


Then I created another item for the Sonoff TH16 switch (the one that will later switch the fan) to blow out the Co2.
See:
Worked right away : proud!!
See the working sitemap and the frontend
co2_sitemap


(Rob) #25

Still not clear:

  • I have to refresh the page to renew the values
  • I would like to visualize the values in a graph and don´t know how
  • Can i use the rule that you created months ago to switch the fan on at a level of 2000ppm and switch it on at a falling level of 1500 ppm and below?

good night…


(Rob) #26

var Timer timer

rule “Too much CO2”
when
Item_co2 received update
then
if (Item_CO2_.value > 1500) {
if (timer === null) {
Item_Ventil.sendCommand(ON) //turn on the vent
timer = createTimer(now.plusMinutes(10), [ | //start and create the timer
Item_Ventil.sendCommand(OFF) //end of timer action
timer = null //reset the timer
] )
}
}
end


(Vincent Regaud) #27

Please use the code fences


(Rob) #28

Hi Vincent,
I created the co2.rules in the rules directory. The item ventil (see above) ist steering the sonoff relais, which is working via mqtt. I could test it positiv via a switch in my sitemap


(Rob) #29


(Vincent Regaud) #30
rule “Too much CO2”
when
    Item_co2 received update
then
    if (Item_co2_.state > 1500) {
        if (timer === null) {
            Item_Ventil.sendCommand(ON) //turn on the vent
            timer = createTimer(now.plusMinutes(10), [ | //start and create the timer
                Item_Ventil.sendCommand(OFF) //end of timer action
                timer = null //reset the timer
            ] )
        }
    }
end

(Rob) #31

Yes of course … fences… are there just beeing ruined by the editor.
sorry!

ps: in a world without borders and fences who needs gates and windows ;-)))


(Rob) #32

how can i test if Item_Ventil.sendCommand(ON) //turn on the vent really works. I doubt a bit that “ON” will passed on correctly to the mqtt string. see items:


(Vincent Regaud) #33

I can’t read that
Please copy and paste the text


(Rob) #34

Switch ventil “Entlüftung” (LR,gLight) { mqtt=">[ohbroker:cmnd/ventilator/POWER:command:*:default], <[ohbroker:cmnd/ventilator/POWER:state:default]" }


(Rob) #35

if you click on the jpg it would show you the text larger.


(SiHui) #36

What about:
Switch ventil “Entlüftung” (LR,gLight) { mqtt=">[ohbroker:cmnd/ventilator/POWER:command:*:default], <[ohbroker:cmnd/ventilator/POWER:state:default]" }

:grinning::sunglasses:


(Rob) #37

Aehm … yes the switch is working perfectly right, i just doubt that the quote… Item_Ventil.sendCommand(ON) in the ruleset will work… and how can I test that?


(Rob) #38

:flushed: ok understood:

Codefences

(Rob) #39

Aehm … yes the switch is working perfectly right, i just doubt that the quote…

Item_Ventil.sendCommand(ON)

in the ruleset will work… and how can I test that?


(Rob) #40

sorry for my “slow wire” …:worried:


(Vincent Regaud) #41

Trigger the rule by changing the value if item_co2 with the rest api

And you are using tasmota aren’t you?

then:

Switch ventil “Entlüftung” (LR,gLight) { mqtt=">[ohbroker:cmnd/ventilator/POWER:command:*:default], <[ohbroker:stat/ventilator/POWER:state:default]" }