Man/Auto mode switch

@hmerk @rlkoshak can you help with this please… I’ve stared at this many times and cannot see what is wrong with this:…

		Switch 		item=i_HVAC_CH_Switch_Proxy			label="Central heating"	 				icon="fire-on"			visibility=[i_HVAC_CH_Switch == ON]			mappings=[ON="ON",OFF="OFF",AUTO="AUTO"] 
		Switch 		item=i_HVAC_CH_Switch_Proxy			label="Central heating" 				icon="fire-off"		visibility=[i_HVAC_CH_Switch == OFF]		mappings=[ON="ON",OFF="OFF",AUTO="AUTO"] 

The fire-on is displayed even when i_HVAC_CH_Switch == OFF and i_HVAC_CH_Switch_Proxy == AUTO

??

Rule

rule 
    "HVAC_CH"
when
    Item g_TRV_Actual_Temperature changed 
    or
    Item g_TRV_Set_Temperature changed 
    or 
    Item i_HVAC_CH_Switch_Proxy changed
then 
    // Check if boiler can be turned OFF or ON in Auto mode
    if (i_HVAC_CH_Switch_Proxy.state == "AUTO") {
        
        
        var Number temperature = g_TRV_Actual_Temperature.state as Number
        var Number demand = g_TRV_Set_Temperature.state as Number
        val Number hysteresis = 0.5

        logInfo("HVAC_CH_Off.rules", "CH AuTO mode checking...")
        logInfo("HVAC_CH_Off.rules", "...temperature={} demand={}", temperature, demand)
        logInfo("HVAC_CH_Off.rules", "...using hysteresi, go ON  if temp < {}", (demand - hysteresis))
        logInfo("HVAC_CH_Off.rules", "...using hysteresi, go OFF if temp > {}", (demand + hysteresis))
        
        if (temperature < (demand - hysteresis)) {

            // Turn on
            i_HVAC_CH_Switch.sendCommand(ON)
            logInfo("HVAC_CH.rules", "...CH turned ON by AUTO rule") 
         
        } else if (temperature > (demand + hysteresis)) {
                
            // Turn Off
            i_HVAC_CH_Switch.sendCommand(OFF) 
            logInfo("HVAC_CH.rules", "...CH turned OFF by AUTO rule")
        }
        
    } else if (i_HVAC_CH_Switch_Proxy.state == "ON") {

            // Turn ON by user demand
            i_HVAC_CH_Switch.sendCommand(ON) 
            logInfo("HVAC_CH.rules", "CH turned ON by rule")

    } else if (i_HVAC_CH_Switch_Proxy.state == "OFF") {
        
            // Turn ON by user demand
            i_HVAC_CH_Switch.sendCommand(OFF)
            logInfo("HVAC_CH.rules", "CH turned OFF by rule")
    }
    
     

/*
    //Check if boiler needs to be turned ON 
    if (i_HVAC_CH_Switch.state == OFF && (g_TRV_Actual_Temperature.state < g_TRV_Set_Temperature.state)) {
        i_HVAC_CH_Switch.sendCommand(ON)
        logInfo("HVAC_CH.rules", "CENTRAL HEATING turned ON by rule")
    } 
*/
end

events.log

020-01-16 12:37:49.342 [vent.ItemStateChangedEvent] - i_HVAC_CH_Switch_Proxy changed from ON to OFF
2020-01-16 12:37:49.361 [ome.event.ItemCommandEvent] - Item 'i_HVAC_CH_Switch' received command OFF
2020-01-16 12:37:49.387 [nt.ItemStatePredictedEvent] - i_HVAC_CH_Switch predicted to become OFF
2020-01-16 12:37:49.413 [vent.ItemStateChangedEvent] - i_HVAC_CH_Switch changed from ON to OFF
2020-01-16 12:37:50.120 [ome.event.ItemCommandEvent] - Item 'i_HVAC_CH_Switch_Proxy' received command AUTO
2020-01-16 12:37:50.134 [vent.ItemStateChangedEvent] - i_HVAC_CH_Switch_Proxy changed from OFF to AUTO
2020-01-16 12:37:50.198 [ome.event.ItemCommandEvent] - Item 'i_HVAC_CH_Switch' received command OFF
2020-01-16 12:37:50.225 [nt.ItemStatePredictedEvent] - i_HVAC_CH_Switch predicted to become OFF
[12:41:34] openhabian@openhab:~$

openhab.log

2020-01-16 12:37:50.155 [INFO ] [thome.model.script.HVAC_CH_Off.rules] - CH AuTO mode checking...
2020-01-16 12:37:50.161 [INFO ] [thome.model.script.HVAC_CH_Off.rules] - ...temperature=16 demand=15
2020-01-16 12:37:50.171 [INFO ] [thome.model.script.HVAC_CH_Off.rules] - ...using hysteresi, go ON  if temp < 14.5
2020-01-16 12:37:50.179 [INFO ] [thome.model.script.HVAC_CH_Off.rules] - ...using hysteresi, go OFF if temp > 15.5
2020-01-16 12:37:50.200 [INFO ] [smarthome.model.script.HVAC_CH.rules] - ...CH turned OFF by AUTO rule
[12:

On the 3 way switch I went to OFF then from OFF to AUTO

A rule sets i_HVAC_CH_Switch to OFF because in AUTO the actual temp is above the demand temp so turn off boiler which is correct. But the boiler is already OFF because I went from OFF to AUTO , so boiler was already OFF. The events.log shows “…to become OFF” but never forcibly goes to OFF . Could that be it?

I also have widgets only visible in AUTO mode and these correctly occult when Proxy item is ON or OFF, and are displayed correctly when in AUTO so i know the system has the correct Proxy value, and in the log file one can see the rule being activated and turning boiler of OFF , but the fire-on icon is displayed , which is incorrect.

Fire-off is correctly displayed when I move the Proxy item swtich to OFF.

Strange
??

visibility needs to be placed at the end

I didnt get any sitemap errors , even so I have changed to put visibility at end of lines, but, no difference
?

This could be just a visibility refresh issue. You cannot tell which of your two alternative lines you are looking at.
Change the label text for one temporarily, so you know which you have in view.

This is how I use it and it works

Text item=HeatingBoiler label="Heizungsbrenner [%s]" icon="fire-on" visibility=[ HeatingBoiler==ON]
Text item=HeatingBoiler label="Heizungsbrenner [%s]" icon="fire-off" visibility=[ HeatingBoiler==OFF]

Good idea,
So with …

		Switch 		item=i_HVAC_CH_Switch_Proxy			label="Central heating ON"	 				icon="fire-on"		mappings=[ON="ON",OFF="OFF",AUTO="AUTO"] visibility=[i_HVAC_CH_Switch == ON]	
		Switch 		item=i_HVAC_CH_Switch_Proxy			label="Central heating OFF" 				icon="fire-off"		mappings=[ON="ON",OFF="OFF",AUTO="AUTO"] visibility=[i_HVAC_CH_Switch == OFF]

I get the Central heating OFF and Central Heating ON correctly, but when OFF the fire-on icon is displayed. The screen refreshed because I see *Central heating OFF in AUTO mode. I refreshed the browser for ten times.

? ?

Hover over the icon and find out the image name. I note that fire.svg and fire-on.svg are the same image in default iconset.
Remind of UI in use? Android app?

mm, but you do not have any mappings, and yours are Text not Switch

it is fire-off.svg , but displaying the fire on , bizarrely

both Android, and Chrome browser on PC

Let’s be really clear, you are relying on the built in iconset fire.svg fire-on.svg fire-off svg - and definitely have no icons of those names in your /classic/icons folder?

I still have doubts about the icon picker behaviour here.
It will look for fire-off-auto.svg in the first case.
That’s fine and normal, it will find nothing and go into fallback.
My doubt is whether it then defaults to fire-off.svg (a kind of rule-bender) or to fire.svg (playing by the rules)

My request for what the UI thinks the image was called was dumb by the way - whatever image the iconpicker actually serves up, the UI thinks it is fire-off.svg

Personally I would abandon all this and make two custom icons fireoff.svg and fireon.svg just to get going!

2 Likes

Let’s be really clear, you are relying on the built in iconset fire.svg fire-on.svg fire-off svg - and definitely have no icons of those names in your /classic/icons folder?

Yes I am, and I have zero icons in $OPENHAB_CONF/icons/classic ,i.e. /etc/openhab2/icons/classic

Personally I would abandon all this and make two custom icons fireoff.svg and fireon.svg just to get going!

I have read the icon docs and I’m confused.
Take “fire off”…
do I create fireoff.svg or fire-off.svg and what name do I put in the sitemap’s icon="<name"> , fireoff fire-off or off when sitemap visibility is set to i_HVAC_Switch==OFF

The hyphen is the magical icon picker part. You are not “supposed” to put hyphens in icon names, for fear of unexpected action by the icon picker. Now we’re trying to avoid that.

someicon.svg in custom icons folder is effectively a one-member iconset. When icon picker is tasked to serve this icon, whatever the associated Item state, it’s the only one it can serve.

In other words, it behaves as a plain simple icon. You put icon=“someicon” in your sitemap, that’s what you get.

So
classic/icons/myfireiconon.svg (a copy of fire-on image)
classic/icons/myfireiconoff.svg (a copy of fire-off image)
will circumvent any picker interference.
You’re specifying the names directly in your sitemap using visibility and do not want picker interfering, do not want states to be considered.

1 Like

ok @rossko57, understand now. And that is what I want, to remove the icon picker. Just looking at the HTML render source …

<div class="mdl-form__row mdl-cell mdl-cell--6-col mdl-cell--8-col-tablet mdl-form__row--hidden">
	<span class="mdl-form__icon">
		<img data-icon="fire-on" src="../icon/fire-on?state=AUTO&format=svg&anyFormat=true" />
	</span>
	<span  class="mdl-form__label">
		Central heating ON
	</span>
	<span  class="mdl-form__value mdl-form__value--group">
		
	</span>
	<div
		class="mdl-form__control mdl-form__buttons"
		data-control-type="buttons"
		data-item="i_HVAC_CH_Switch_Proxy"
		data-has-value="false"
		data-count="3"
		data-widget-id="0002"
	>
		<button 
	class="mdl-button mdl-button--raised mdl-js-button mdl-js-ripple-effect mdl-button" 
	data-value="ON"
>
	ON
</button>
<button 
	class="mdl-button mdl-button--raised mdl-js-button mdl-js-ripple-effect mdl-button" 
	data-value="OFF"
>
	OFF
</button>
<button 
	class="mdl-button mdl-button--raised mdl-js-button mdl-js-ripple-effect mdl-button--accent" 
	data-value="AUTO"
>
	AUTO
</button>

	</div>
</div>
**<div class="mdl-form__row mdl-cell mdl-cell--6-col mdl-cell--8-col-tablet ">**
**	<span class="mdl-form__icon">**
**		<img data-icon="fire-off" src="../icon/fire-off?state=AUTO&format=svg&anyFormat=true" />**
**	</span>**
**	<span  class="mdl-form__label">**
**		Central heating OFF**
**	</span>**
**	<span  class="mdl-form__value mdl-form__value--group">**
		
	</span>
	<div
		class="mdl-form__control mdl-form__buttons"
		data-control-type="buttons"
		data-item="i_HVAC_CH_Switch_Proxy"
		data-has-value="false"
		data-count="3"
		data-widget-id="0003"
	>
		<button 
	class="mdl-button mdl-button--raised mdl-js-button mdl-js-ripple-effect mdl-button" 
	data-value="ON"
>
	ON
</button>
<button 
	class="mdl-button mdl-button--raised mdl-js-button mdl-js-ripple-effect mdl-button" 
	data-value="OFF"
>
	OFF
</button>
<button 
	class="mdl-button mdl-button--raised mdl-js-button mdl-js-ripple-effect mdl-button--accent" 
	data-value="AUTO"
>
	AUTO
</button>

	</div>
</div>

I note the lines I have starred with ** , the icon referenced is fire-off but the state to the icon selector (?) is AUTO so is it looking for fire-off-AUTO.svg (which doesnt exist nor does fire-on-AUTO.svg_ and so it defaults to fire and uses the default on ??
or
Could it be my mappings ON= , OFF= and AUTO= should be on= , off= and auto= possibly?

More or less. The picker takes care of upper/lowercase, just ignore that.

Whether the picker defaults to seeking fire or fire-off is unknown to me, but fire only is consistent with your observations.
Remember, fire happens to look the same as fire-on in this instance.
As I said, the “filename” the UI thinks the image has is not the filename the picker actually got the image from.

I think it works for Hans because his states happen to be on and off, no auto.

1 Like

Quite agree with you on Hans’ setup.

So what icon filenames should I use in the filesystem and what name in the icon= sitemap? or could I use combinations of visibility= to AND the conditions such that I can pick icons when i_HVAC_CH_Swtich==ON and i_HVAC_CG_Switch_Proxy==AUTO ??

I’m baffled here now and loosing the plot :slight_smile:

Anything you like. From the docs - Icon filenames may include lowercase letters, numbers and underscores

I’m not sure what is unclear about

Let’s edit it down

someicon.svg in custom icons folder behaves as a plain simple icon.

You put icon=“someicon” in your sitemap, that’s what you get.

Sorry, I meant I understand what you say but it is not what I seem
because whatever I do, it doesn’t work .
I have ch_on.svg and ch_off.svg and put these in the sitemap icon=
Just didnt work, still showing the fire icons !!! Weird

BUT

I have been using BasicUI and I just went to my Android, OpenHAB app, and with my custom ch_on.svg and ch_off.svg icons , it WORKS !

Back to BasicUI and the fire icons are still being shown , incorrectly.

There’s a bug I’m sure because when I used fire svg icon names and in the sitemap , as above , it didnt work.

Only works by renaming the icon files to something other than fire and only using the android App

How strange

But wait @rossko57 …it gets better…

If I login at www.myopenhab.org and open up BasicUI , it now is correct , the fire icons work as expected. Back to BasicUI on my LAN, and it’s still wrong. Logged out logged back in - same. Reset WiFI network - same. Really really strange

Clear the browser cache perhaps.

2 Likes

hell, didn’t think of that

Yep, that’s done it, works now.

Marked Solved although I really want to mark your and @rossko57 as Solved. Can’t do both :frowning:

Would be interesting if my config works as well at your snstallation after clearing browser cache