Can not initialize Setpoint Value

Using Setpoint Item to vary sprinkler timer value. Initial values are blank even though min and max values are established. Up and down buttons are unresponsive using chrome and safari. From my android phone i am able to set the initial values and then chrome, safari works. Crazy! any suggestions?

The initial value comes from the Item, not the min and max values set on the sitemap’s setpoint. So if you don’t have a value it means your Item is undefined (i.e. has no value yet).

It sounds like a bug in the webapp when dealing with setpoint Items that are undefined. What do you thing @watou? Given that the Android app is able to give the Item a value it isn’t all that crazy that the web app works after that.

I highly recommend setting up persistence on these items using the restoreOnStartup strategy so you don’t lose their values when OH restarts. This will work around the problem as well as your Items will no longer be undefined when OH restarts.

If a Number item does not have a numeric value but is instead Undefined or Uninitialized, it makes no sense that the up or down Setpoint buttons would do anything. Per your description, it would seem like incorrect behavior of the Android app to let you use the up/down buttons if the item’s state is not a numeric value within the min and max range. In other words, when you press the Up button to increase a numeric value up to an allowed max value, but your item does not even have a numeric state, what do you think it should do?

So I would follow Rich’s advice and make sure your item has a numeric value, possibly by using restoreOnStartup with a persistence service.

I will read up and look for some examples of your suggestion on restoreOnStartup. As a quick fix i tried the following without success. Bottomline is I am not sure where I should be putting the initial values for my setpoints(rules, items, sitemap). Tried the rule below following a reset on a switch. Doesnt work.

The rule should then trigger on “System started” and you sould no define a variable you schould use Drip_Secs_Set_Point.sendCommand(10.0)

Thomas

Should that not be

Drip_Secs_Set_Point.postUpdate(10.0)

@ watou

Depends. I would say that depens on the item. I prefer the sendCommand, because the item is then in a defines state. If i use postUpdate, only the openhab item ist defined but until the openhab items gets an update from the physical item both values can differ from each other.

Thomas

THANKS!! That fixed it. Clearly I need to find a better source of
instruction. Spending way too much time searching for pieces of code that
can be hacked together. Stupid question but how would someone know to use
"postUpdate", etc? What did I miss out on while studying Mechanical
Engineering all those years ago? Thanks Again!!

1 Like

The wiki has a lot of great information about how OH works and lots of explanations.

What is not clear to me in this example – and what the OP also asked:
Where does the initial value come from?

If I set it in a rule, wouldn’t is always be that defined number, rather than the last one I have selected?

I am trying to make a Setpoint work, and get uninitialised (like the OP).

In my case I want to change the minimum level of a water tank to trigger a refill.

By default it is 85%, but once changed it should be the changed value (from then on).

What do I need to do to get there?

My item is:

Number   cfgDemandLevel	"cfgDemandLevel [%s %%]"	{mqtt=">[mymosquitto:ArgyleCourt/Property/IrrigationTank/DemandLevel:command:*:default]"}

The sitemap:

Setpoint item=cfgDemandLevel minValue=10 maxValue=90 step=5

persistence:

cfgDemandLevel : strategy = everyChange, everyMinute, restoreOnStartup

Any help appreciated.

Ultimately you need to bootstrap the Number Item with a value before the Setpoint will work. You can do this using a System started rule that you only keep around for one trigger to populate the Number with an initial value and then rely on persistence and restore on startup to preserve the value from then on.

1 Like

Thank you kindly!!

This works!!!

What I did (for the benefit of other newbies):

// ----- 161229 MaxG: Bootstrap irrigation tank minimum level
//                    required (only once) for set point to work,
//                    after that persistence will take care of it. Thanks Rich!
rule "Bootstrap irrigation tank minimum level"
  when
    System started or
  then
    logInfo("InitFillLevel.rule", "set cfgDemandLevel: {}", cfgDemandLevel)
    cfgDemandLevel.sendCommand("85")
end
2 Likes

I use this

rule “StartupBath”

when
System started
then
if (RailRun1Time.state==NULL) RailRun1Time.sendCommand(0)
end

1 Like

Are you saying an non-initialised value = NULL?
If so, fair enough, and this should work too, without having to uncomment the rule after it ran once.

That’s my understanding :slight_smile: - only based on reading these forums, so happy to learn a better way

I tested this for an item of type Number and it worked fine.

Number test47 "test value [%s]"
if (test47.state==NULL) test47.sendCommand(47)

resulted in test47 being 47 (and this item is not referenced anywhere except the startup rule)

Thank you, I will try.