Im using openhab to connect to a modbus slave tcp/ip device.
This works great and im able to read temp and write with switches or dimming objects.
My issue is when im using network health bindings i want the value of my phone to be sent to a modbus point. I made this item and a switch, when i click on my phone that works. Next step was to add the network health binding to the same item, but there is where it stops. After debugging it seems the point is not “sent” like when i use a switch, then it will be sendt, so when my phone is connecting to the network the item updates to “On”, but the “On” (true) is not sendt.
I have tried to make a script with somthing simple in rules, but here is my weakness, can somebody please help and see if i use a “illegale statment” or just a small type?
rule "Turn off"
when
Item Phone changed
then
if (Phone == OFF)
Thanks for the quick feedback.
The end was just a copymistake, but i see you have a different syntax then me with Phone.SendCommand(On) and maybe that will help!
But will this also send “Off” if not, or should i do something like this:
Will that work and is my syntax ok?
rule "Turn off"
when
Item Phone changed
then
if (Phone == ON) {
Phone.sendCommand(ON)
}
else
if (Phone == OFF) {
Phone.sendCommand(OFF)
}
end
It’s worth a try. It may not work, depending on how your item ‘Phone’ is configured and how your mystery modbus device updates that (alongside the network health binding).
You may need to have two Items, one to reflect the network health state, one to handle modbus. And a rule to command modbus when net health changes.
Or you might want to try having a “write only” modbus Item so that updates cannot conflict.
Did not work
The modbus decives is a JACE250 from Niagara. It already talk to 200modbus points and it works very good.
There is nothing that writes on this object on clientside, so there should be no conflict if i understand this correct.
If i changed the object to a switch, so i can push on it on the app, then it works fine, but thats the whole point, not to push on it. How would a rule for command modbus when net health changes look like?
Its worth looking at your logs when things ‘not work’, you may be able to see why.
In my example I forget to put Phone.state in the if() statement, rather than just Phone. Try that.
rule "pass event"
when Item PhoneNetHealth changed
then
if (PhoneNetHealth.state == ON) {
ModbusItem.sendCommand(ON)
} else {
ModbusItem.sendCommand(OFF)
}
end
I want to do the same but this time with an value.
Tried to guess something, but does not work.
Would you please correct me? I want the temp to be sent to a modbus address when its changing.
rule "KleppeveienKontor"
when
Item KleppeveienKontorTemp.value changed
then
KleppeveienKontorTemp1.sendCommand (value)
Thats correct, its a number item.
So it should be the same as a switch? I thought maybe .state was a “digital” (on/off)
What should be in the () where in my other case it was on/off, now i want to see the temp value, so i just guessed (value), but it that correct?
KleppeveienKontorTemp1.sendCommand (value)
I have tryied to read up to really learn rules. I come for a Building automation backround with blocks and are trying to do more and more in rules, but i struggle to find alot of information about this, i have tried to forum and wiki, but i struggle.
Im also trying to do some simple rules that based on a switch sets the SP to comfort or saving.
Do you have any links to recommand? I will really appricicate it!
Here’s a variant of something from right within this thread
rule "pass command"
when Item SomeSwitch received command
then
if (receivedCommand == ON) {
WhateverAnSPItemIs.sendCommand(ON)
} else {
WhateverAnSPItemIs.sendCommand(OFF)
}
end
This would work if it was a “smart thermostat” but this is just IO.
So i have a internal switch in OH that state Home/Away.
If it is Home then the SP is 22 degress celsius (internal point that i want to adjust)
If it is Away then the SP is 16 degress celsius (internal point that i want to adjust)
Then based on this i need a controll that are looking at the temp and SP and turn off/on the heater. It should also be some kind of min/max time or 0,5 celsius diff so it is not going off/on alot.
In blocks this is easy, but with rules i dont see how to do this. i have tried to google forum, google groups and wiki but i cant find example on this.
If you have any place i can read how to do this i would really appricate it.
I don’t know what SP is (set point?), I don’t know what blocks are, I don’t know what you are trying to achieve.
I’m guessing you want to write a rule that acts as a thermostat? You have some temperature measurement as a Number item, and you have a Switch item that simply turns a heater on or off?
Sorry for the short desciption. SP is setpoing yes.
I want to archive almost the same as simple Thermostat rule, but i also want to add the home/away switch.
I have a switch that says if i am home or away. (on is home off is away)
If i’m home (switch is on) than my current setpoint is HomeSetpoint
If i’m away (switch is off) then my current setpoint it Away setpoint.
This has to be done in openhab as a virtual point.
Then maybe i can use the same rule as simple thermostat but my setpoint can change from two item, based on the switch.
Did this makes more sense?