State of item controlled through other items

Hi there, I am struggling to find a solution to this challenge;

I have a numbers item, item1, which gets reviewed towards the output of a python script every 60 sec by a rule and a CRON. The item contains the setpoint temperature my pellet stove should regulate its heating towards. Every time the value changes in the stove, it is synced to item1 within 60 sec.

I can affect the setpoint value in the stove, either by its own interface (on the stove) or by sending a new setpoint value to the stove through another python script - tiggered through a command by the EXEC-binding. This works - and the value is synced back to item1 within 60 sec.

Now, I would now like to also have the option to show and pick this setpoint value in my sitemap like this;
Setpoint item=item1 minValue=15 maxValue=25 step=1

It may work - but I risk getting issues due to the delay in syncing. This means that a selected setpoint value may get back-synced due to the sync-delay…

In principle I would like an item to have its status shown based on one other item - and changes affecting the contents of another item. Like in the MQTT binding channels where I can make different statements in the binding info in the items-file like this;
Switch itemX { mqtt="<[broker1:XXXX/gpio/15:state:default],>[broker1:XXXX/gpio/15:command:ON:0],>[broker1:XXXX/gpio/15:command:OFF:1]" }

Any suggestions ?

A 1 minute polling period seems pretty long. I’m sure 15 seconds would add no measurable impact to the system in comparison. Even every second would probably not be too much. I would see how quickly you can get the polling period down to and if it’s supportable see if you still have this problem.

You’re going to have to use a Rule for this. A Rule wouldn’t be required for all bindings (even the MQTT 2.x binding could do this without a rule, note that you are showing the MQTT 1.x binding syntax) but because you are using the Exec binding a rule is going to be required. In fact you need a Rule and a proxy Item because the Exec binding only supports String Items but the slider widget on the sitemap only supports Number Items.

So create a proxy Item.

Number Stove_Setpoint "Stove Setpoint [%d]" { autoupdate=false }
String Command_Stove { channel="exec:blah:blah:blah" } // Linked to input Channel on Thing that commands the stove 
String Status_Stove { channel="exec:blah:blah:blah" } // Linked to output Channel on Thing that gets the current setpoint from the stove

The autoupdate=false will prevent the Item from changing state when you command it from the sitemap. It will not change state until the stove reports a new state.

Then you need a rules to keep them in sync.

rule "Setpoint changed, command the stove"
    Item Stove_Setpoint changed

rule "Stove changed"
    Item Stove_Status changed

The postUpdate will change the Item’s state without executing the script again to command the stove.

1 Like

Makes sense :wink: However, I get an error due to the {autoupdate = off}

2020-10-27 22:40:09.867 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘test.items’ has errors, therefore ignoring it: [470,60]: mismatched input ‘false’ expecting RULE_STRING

Definition in test.items:
Number Xsettemp “Settemp [%.1f °C]” { autoupdate=false }

Looks like the false needs to be in quotes.

Yep, it compiles well enough then.

It does work now - but the changed setpoint does not update in the sitemap when pressing UP - and it does not update after going through the cycle of syncing. Strange. I need to give it a think myself and then perhaps sharing more details from my rules…

You can simultaneously have another sitemap line, a simple text widget perhaps, showing what the UI thinks the Item state is.

With autoupdate disabled, commands will need to make the round trip to the device and back via poll before the Item state changes.
With autoupdate enabled, you get a responsive UI.

I’d be looking at coding to invoke a poll a short time after a command. "Normal’ polling could stay infrequent - how often does this change, do you care much, etc.

OK - played around with autoupdate=false or not - and sendCommand vs. postUpdate - and now finally got it working the way it should.
I need to clean up my code a bit and post the whole thing as an example :wink:
Thanks a million for all the help and support; paving the way with ideas is often a much better way of learning than just copying a working solution !