I have now dealt with Profiles for the first time and have read the documentation: Items | openHAB.
It was unclear to me whether, for example, the hysteresis value is also set back to OFF in a certain situation (which I presumed), but this is not explicitly mentioned in the doc, so I looked at the code and yes, this happens in mapValue.
This Profile can be used to trigger alarms when number values exceed a given lower bound - sends ON to the Switch Item.
FYI: low == OFF, high == ON unless inverted is on. upper equals lower, if no upper is given.
Should we add the to the description when exactly the item is set back to OFF? Is the following understanding correct?
in case only lower value is given (is this really a hysteresis then?) it sends OFF to the switch, when the value falls below or is equal to lower.
in case an upper value is provided, ON is only sent when it exceeds/equals the upper value and keeps it until then falls below/equals lower and the OFF is sent to the switch item.
the values ON/OFF are inverted if inverted is set.
Do I understand it correctly ^ and if yes, does it make sense to add a more comprehensive documentation to the description? (I am happy to to that for this profile and the others that send ON/OFFS)
I’m always for having the docs be explicit and complete. This does seem like an important part that’s missing.
What does upper and high default to? Given this code snippet I don’t see how the upper check can be skipped. These have to have some value so it’s not a half hysteresis, it just defaults the high bound. documenting what that default is would be useful though.
Given that, the mapValue will return low or previousType which is set to UNDEF. But that can only work in cases where a stateUpdate is sent to the Item. If the Profile is configured to sendCommand, the UNDEF is ignored because it’s not a Command.
My reading of the docs indicated that it always sends the command so indeed, without the upper defined, it will only send low as a command or nothing at all.
At least that’s how I read the code, but I wonder under what circumstances, if any public void onStateUpdateFromHandler(State state) would ever be called. If there is one, than the behavior is the Item will be updated to low or UNDEF. Maybe whether it’s a command or update depends on whether the Channel is sending a command or posting an update.
The Hysteresis Profile acts similar to a threshold when no upper value is given. In this case upper is set to the same value as lower and the mapValue can be interpreted like this:
if (value <= lower) {
return low;
} else if (value >= lower) {
return high;
}
return previousType;
Meaning it either returns low (OFF) or high (ON) or the other way around if inverted=true.
The hysteresis logic applies only if both lower and upper are set.