Switch not turnning on

Hello,
I have a problem which I cannot solve.
My switch item bathroom fan(named as ventilator) has a rule that turns it on. The rule works 100% correctly, in the BasicUI the switch turns on and off correctly. But in reality the switch is not turning on.
Switch is connected via qpio.

code:
items
Switch ventilator "ventilator" {qpio="pin:20 activelow:yes initialValue:high" }
sitemap
Switch item=ventilator icon="fan_ceiling"

and for example here is the code for the other switch which works just fine.
items
Switch luc "luc" { gpio="pin:26 activelow:yes initialValue:high" }
sitemap
Switch item=luc icon="lightbulb"

Tried different pins and no success.

and here is the rule for bathroom fan.

val Number maxHumidity = 90
val Number minHumidity = 70

rule "fanBathroom"
  when
    Item Humidity changed
  then
    logInfo("FanBathroom", "Humidity changed to {}, ventilator is {}", Humidity.state, ventilator.state)
    if (ventilator.state != ON) {
      if ((Humidity.state as Number) > maxHumidity) {
        logInfo("FanBathroom", "Humidity {} above threshold of {}", Humidity.state, maxHumidity)
        ventilator.sendCommand(ON)
      }
    }
    if (ventilator.state == ON) {
      if ((Humidity.state as Number) < minHumidity) {
        logInfo("FanBathroom", "Humidity {} below threshold of {}", Humidity.state, minHumidity)
        ventilator.sendCommand(OFF)
      }
    }
 end

Not sure I understand fully, but what I am reading is the following:

  • your rule triggers and executes correctly
  • your sitemap indicates the desired state
  • only in reality your fan does not come on
  • and your setup for ventilator is the same as that for luc, which actually does work

If the above is correct, then I would venture to guess that you are having a hardware problem. As on the software side everything appears to work as intended. The use of GPIO’s can be tricky and you would need to do hardware debugging; e.g., check if the GPIO actually changes state as intended by using a LED or similar; if so, check what happened in your circuit that deals with the fan, etc.
But maybe I am off base here…

I doubt you have a qpio binding
Your Item that works is bound to gpio

Fixed the problem.
Solution
item
Switch fan "ventilator" { gpio="pin:20 activelow:yes initialValue:high" }

sitemap
Switch item=fan icon="fan_ceiling"

rule
val Number maxHumidity = 90
val Number minHumidity = 70

rule "fanBathroom"
  when
    Item Humidity changed
  then
    logInfo("FanBathroom", "Humidity changed to {}, ventilator is {}", Humidity.state, fan.state)
    if (fan.state != ON) {
      if ((Humidity.state as Number) > maxHumidity) {
        logInfo("FanBathroom", "Humidity {} above threshold of {}", Humidity.state, maxHumidity)
        fan.sendCommand(ON)
      }
    }
    if (fan.state == ON) {
      if ((Humidity.state as Number) < minHumidity) {
        logInfo("FanBathroom", "Humidity {} below threshold of {}", Humidity.state, minHumidity)
        fan.sendCommand(OFF)
      }
    }
 end

Hmmm, just changing the name of the item shouldn’t be the solution…

1 Like

You are right, but I’ve tried many things changed relay, pins,… and none of these worked.

Well, spelling gpio in the binding part of the Item definition rather than qpio probably has something to do with it.

4 Likes

Good catch!