Common sitemap group

I’m not sure if this is doable in OH.
If i have some setpoint items linked to a Number items and i need to display these setpoints under different groups in the sitemap (ex: i need to display it under the Bedroom and Living room groups), should i duplicate the same code over and over ?
Is there any way to put the setpoints in a group or something and just add that group to the rooms ?
I’ve tried adding the Number items of the setpoints to a group but they get displayed as text only and can’t be edited.
Basically, what i’m trying to do is create a common alarm form to set a specific action from each room and i don’t want to have items for each room. The idea is to have 1 common timing form and store the data in a Map or database and use that data to perform the actions.

No, just add them to both Groups. Or if you are not using Groups to create your sitemap put the items in multiple places on the sitemap. Nothing says you can’t have an item in more than one place.

Yes but you have no control over how they are rendered. You can’t specify the order, override the label or icon, or use sitemap features like visibility or color.

Now this is more difficult. There is no way with sitemaps to create a form. There is no way in Rules to query a database.

Perhaps some example code would make it more clear what you are trying to do.

Hi Rich,
Thank you for your reply.
The main reason i’m doing this is because i need a simple scheduler for some of my items. I have an irrigation system that consists of 5 zones and i need to set the time when each zone is turned ON and OFF but i don’t want that to be hard-coded. I want to be able to change that from my sitemap for each zone.
Currently this is what i have

This is for the my first zone only. I feel that it’s pretty complicated to have to repeat the form for each zone just to get a simple scheduling functionality.
can you advise if there is an easier way for doing this ?

Perhaps you could construct a sitemap ‘form’ that allows you to alter times etc into a set of dummy items, and includes a selector for the target zone. When finished, press a ‘done’ button and have a rule load the dummy values into your actual zone.

this is not correct, you can query a database in a rule and also store values from a rule into a database
all you need to do is to run executeCommandLine with an db-query-script

in my case i use mycli to access my mariaDB, the script takes the item name as input, convert the name to lowercase, search the according table, when there is no second input it will returns the first value of the table. In case there is a second input the script will write the second input into the db of course only if the value is in the right format (numbers <=> strings)

rule "db read / write"
 <trigger event>
    // read value from db 
    var String db_get=executeCommandLine("/home/openhabian/sql.query <item_name>", 5000)
    logWarn("myLog", db_get)
    // write value into db 
    var String db_put=executeCommandLine("/home/openhabian/sql.query <item_name> <value>", 5000)
    logWarn("myLog", db_put)


dbconnect="mycli -h $host -u $user -p $password -D $database --execute"
table=$($dbconnect "show tables like '${1,,}_%'" | awk "FNR == 2")

if [ -z $2 ]
  value=$($dbconnect "select value from $table limit 1" | awk "FNR == 2")
  $($dbconnect "insert into $table (value) values ($2)")
  if [ $? -eq 0 ]
    value="SUCCESS: '$2' written into $database.$table"
    value="check input"

echo $value


Which doesn’t work with MapDB, rrd4j, and perhaps some of the other embedded databases whether there are no command line clients. It also doesn’t work if you do not have the database clients installed on the machine where OH is running (e.g. your database is running on some other machine or your are running OH in Docker).

And making a call to an external script or program really isn’t within Rules.

Is it possible to get data from a database into OH. We’ll if you can rely on implementing it outside the Rules you can do anything, under the right circumstances.

So there is no way to do what you are after in the sitemap. You will have to duplicate the section for each zone.

But most people, when faced with this problem really to the CALDav binding or GCal binding (I think the later is still around) and schedule things though a calendar.
Alternatively, you can use HABPanel and create a custom irrigation widget.

ok to this i can agree :wink:

Thank you all for your replies.
That is kind of what i was trying to do. To have a single form save values to a database and apply my rules in OH rules or using external scripts if possible.
I will take a look at the GCal.
I prefer running everything locally without depending on cloud services whenever possible so i hope that it runs locally.

Given the G in GCal stands for “Google”…

But the CalDav binding will work with other services like OwnCloud.