HPEx - HabPanel Extension

Lucky!

You are the MAN! I believe this functionality / feature set should be part of the OH HabPanel standard build.

This allows you to control 3 different tablets using HabPanel with 3 different screen saver / theater mode settings all with rules now.

Great job!

Best, Jay

Here’s my working config:

items

// Vertical Tablets
Switch	Bedroom_Mode_Switch				"Upstairs Bedroom Mode [MAP(On_Off.map):%s]"						(HomeState)		[ "Switchable" ]
String	habpanelEx_Bedroom_V			"[%s]"																(HomeState)

Switch	Theater_Mode_Switch				"Basement Theater Mode [MAP(On_Off.map):%s]"						(HomeState)		[ "Switchable" ]
String	habpanelEx_Basement_V			"[%s]"																(HomeState)

// Horizontal Tablet
Switch	LivingRoom_Mode_Switch			"Livingroom Mode [MAP(On_Off.map):%s]"								(HomeState)		[ "Switchable" ]
String	habpanelEx_Livingroom_H			"[%s]"																(HomeState)

sitemap:

	Frame label="Tablet Displays" {
    	Switch item=Theater_Mode_Switch				icon="cinemascreen"		label="Basement Theater Mode"
    	Switch item=Bedroom_Mode_Switch				icon="bedroom"			label="Up Stairs Bedtime Mode"
    	Switch item=LivingRoom_Mode_Switch			icon="office"			label="Living Room Mode"
	}

rules:

rule "Tablet in Bedroom Set Screen Saver Mode ON at 8 PM"
    when 
        Time cron "0 00 20 ? * * *"		// 8 PM Daily
    then 
	
		Bedroom_Mode_Switch.postUpdate(ON)		// Turn Tablet Screen Saver ON
end


rule "Tablet in Bedroom Set Screen Saver Mode OFF at 8 AM"
    when 
        Time cron "0 00 8 ? * * *"		// 8 AM Daily
    then 
	
		Bedroom_Mode_Switch.postUpdate(OFF)		// Turn Tablet Screen Saver OFF
end

rule "Enjoy the show in the Basement"
	when
    	Item Switch_Basement_Light changed to OFF
	then

		Thread::sleep(5000)  // 5 second wait

    	if (Basement_TV_Power.state != OFF && Basement_Power.state != OFF && Onkyo_Basement_Power.state != OFF) {			// ONKYO and SELF Defined & TV

			// Turn Tablet Screen Saver Black
			Theater_Mode_Switch.postUpdate(ON)
				Thread::sleep(1000)  // 1 second wait

			if (Alexa_Status.state == 'ONLINE') {

				logInfo("Echo", "-----------------------------------------------------------------------------")
				logInfo("Echo", "** Echo Speaking on Basement")
				logInfo("Echo", "-----------------------------------------------------------------------------")
				if (Echo_Basement_textToSpeechVolume.state != '70' ) { Echo_Basement_textToSpeechVolume.sendCommand('70') }
					Thread::sleep(2000)  // 2 second wait
       			Echo_Basement_TTS.sendCommand("  Excuse me, Please enjoy the show and don't forget your buttered popcorn.")
					Thread::sleep(2000)  // 2 second wait

				logInfo("Echo", "Echo speaks - Excuse me, Please enjoy the show and don't forget your buttered popcorn.")
			}

			if (currMonth !== null)		{currMonth = now.getMonthOfYear}					// update the current month
			if (currMonth != 12){

				var DecimalType hue = new DecimalType(39)		// 0-360; 0=red, 120=green, 240=blue, 360=red	// Dark Tangerine
				var PercentType sat = new PercentType(87)		// 0-100
				var PercentType bright = new PercentType(100)	// 0-100
				var HSBType 	light = new HSBType(hue,sat,bright)

				BarLedge_Dimmer.sendCommand(new PercentType(100))
    			BarLedge_Color.sendCommand(light)
					Thread::sleep(2000)  // 2 second wait
    			BarLedge_Color.sendCommand(light)
					Thread::sleep(2000)  // 2 second wait

			} else if (currMonth == 12){

				var DecimalType hue = new DecimalType(7)		// 0-360; 0=red, 120=green, 240=blue, 360=red   // Scarlet Red
				var PercentType sat = new PercentType(100)		// 0-100
				var PercentType bright = new PercentType(98)	// 0-100
				var HSBType 	light = new HSBType(hue,sat,bright)

				BarLedge_Dimmer.sendCommand(new PercentType(100))
    			BarLedge_Color.sendCommand(light)
					Thread::sleep(2000)  // 2 second wait
    			BarLedge_Color.sendCommand(light)
					Thread::sleep(2000)  // 2 second wait
			}

			Wallplug_Basement_Dehumidifier.sendCommand(OFF)
				Thread::sleep(2000)  // 2 second wait

			logInfo("WeMo", "Dehumidifier turned OFF in Basement because movie is starting")
			logInfo("Echo", "Basement_Power - Basement Annoucement about Enjoying the Show and Onkyo state is " + Basement_Power.state)
			logInfo("Echo", "Onkyo_Basement_Power - Basement Annoucement about Enjoying the Show and Onkyo state is " + Onkyo_Basement_Power.state)

			if (BasementHumidifierDelay_tAlive === null) {

    			BasementHumidifierDelay_tAlive = createTimer(now.plusHours(3), [ |
    			BasementHumidifierDelay_tAlive.cancel()
					Thread::sleep(2000)  // 2 second wait
				BasementHumidifierDelay_tAlive = null

				// Turn Tablet Screen Saver OFF
				Theater_Mode_Switch.postUpdate(OFF)
					Thread::sleep(1000)  // 1 second wait

				logInfo("WeMo", "Dehumidifier turned back ON in Basement because movie is over")
			
				Wallplug_Basement_Dehumidifier.sendCommand(ON)
					Thread::sleep(3000)  // 3 second wait
    			])

			} else if (BasementHumidifierDelay_tAlive !== null){

    			BasementHumidifierDelay_tAlive.cancel()
					Thread::sleep(2000)  // 2 second wait
				BasementHumidifierDelay_tAlive = null
			}
    	}
end

What the items look like when you use HabPanelEX to configure them:

2019-01-31 06:25:18.239 [ome.event.ItemCommandEvent] - Item 'habpanelEx_Bedroom_V' received command {"config_item":"habpanelExConfig","initComplete":true,"isShowInDrawer":true,"screensaver":{"isEnabled":true,"timeoutSeconds":300,"dashboardList":"Weather-Vertical,MainFloor-Vertical,KidsRooms-Vertical,Garage-Vertical","durationSeconds":120,"isFullScreen":true},"theaterMode":{"isEnabled":true,"isOn":false,"color":"rgba(0,0,0,0.90)","triggeringItem":"Bedroom_Mode_Switch"},"panelConfigItem":"habpanelEx_Bedroom_V"}
2019-01-31 06:29:05.530 [ome.event.ItemCommandEvent] - Item 'habpanelEx_Basement_V' received command {"config_item":"habpanelExConfig","initComplete":true,"isShowInDrawer":true,"screensaver":{"isEnabled":true,"timeoutSeconds":300,"dashboardList":"Basement-Vertical,Cameras-Vertical","durationSeconds":120,"isFullScreen":true},"theaterMode":{"isEnabled":true,"isOn":false,"color":"rgba(0,0,0,0.90)","triggeringItem":"Theater_Mode_Switch"},"panelConfigItem":"habpanelEx_Basement_V"}
2019-01-31 06:30:29.740 [ome.event.ItemCommandEvent] - Item 'habpanelEx_Livingroom_H' received command {"config_item":"habpanelExConfig","initComplete":true,"isShowInDrawer":true,"screensaver":{"isEnabled":true,"timeoutSeconds":300,"dashboardList":"Our House,Cameras,Up Stairs,Kids Room,Basement","durationSeconds":120,"isFullScreen":true},"theaterMode":{"isEnabled":true,"isOn":false,"color":"rgba(0,0,0,0.90)","triggeringItem":"LivingRoom_Mode_Switch"},"panelConfigItem":"habpanelEx_Livingroom_H"}

Best, Jay

2 Likes

One happy customer :slight_smile:

1 Like

I discovered an issue with the item re-loading after clearing the cache/tmp directories on OH 2.3.

I have persistence set on the virtual items to store the screen saver settings but after clearing the cache/tmp directories; the item values I had set dis-appeared.

Any recommendations?

Best, Jay

As I mentioned before, the browser remembers the item string through localStorage. So if you clear your browser, you would need to select it again.

Here’s how I resolved it . . . I set the item values in the startup rule.

		// Setting Screen Saver Item Values

		habpanelEx_Bedroom_V.postUpdate('{"config_item":"habpanelExConfig","initComplete":true,"isShowInDrawer":true,"screensaver":{"isEnabled":true,"timeoutSeconds":300,"dashboardList":"Weather-Vertical,MainFloor-Vertical,KidsRooms-Vertical,Garage-Vertical","durationSeconds":120,"isFullScreen":true},"theaterMode":{"isEnabled":true,"isOn":false,"color":"rgba(0,0,0,0.90)","triggeringItem":"Bedroom_Mode_Switch"},"panelConfigItem":"habpanelEx_Bedroom_V"}')
		habpanelEx_Basement_V.postUpdate('{"config_item":"habpanelExConfig","initComplete":true,"isShowInDrawer":true,"screensaver":{"isEnabled":true,"timeoutSeconds":300,"dashboardList":"Basement-Vertical,Cameras-Vertical","durationSeconds":120,"isFullScreen":true},"theaterMode":{"isEnabled":true,"isOn":false,"color":"rgba(0,0,0,0.90)","triggeringItem":"Theater_Mode_Switch"},"panelConfigItem":"habpanelEx_Basement_V"}')
		habpanelEx_Livingroom_H.postUpdate('{"config_item":"habpanelExConfig","initComplete":true,"isShowInDrawer":true,"screensaver":{"isEnabled":true,"timeoutSeconds":300,"dashboardList":"Our House,Cameras,Up Stairs,Kids Room,Basement","durationSeconds":120,"isFullScreen":true},"theaterMode":{"isEnabled":true,"isOn":false,"color":"rgba(0,0,0,0.90)","triggeringItem":"LivingRoom_Mode_Switch"},"panelConfigItem":"habpanelEx_Livingroom_H"}')

		logInfo("Startup Script", "Startup Script Done with - Setting Screen Saver Item Values")
		logInfo("Startup Script", "-----------------------------------------------------------------------------")

This issue doesn’t have anything to do with the browsers at the tablet level; it has to do with clearing items that are virtual on a cache/tmp directory cleanup on the OH server.

Looks like the virtual items are NOT persistent even though I have asked them to be.

We’re all good now . . .

Best, Jay

The items are created using the REST API. If you want them to be truly persistent, go to REST API, and delete those item configs, and just add them through an .items file. Make sure the config is a JSON.stringified string

@luckymallari I have a couple of feature suggestions

  1. Could the screensaver go on after x seconds in combination with another switch? I have a fixed panel for mornings and another for kids chores in the afternoon but would like to Rotate through panels in times other than this. Having a switch item in the config, I could then turn this in and off with cron rules
  2. Could you prioritise theatre mode? Looks like if screensaver is running theatre mode doesn’t kick in
  3. Any way to return from screensaver to a specific panel?

Love your work

Been busy. Will work on this soon

Question, I keep losing the settings for HPEx on my raspberri pi. I do not fully understand how the panel settings sync to the server. Would anyone have details on how/when does the settings get sync-ed to the server?

Been running mine for over a year now; here’s how I got it setup on 3 different panels. Two are vertical and one is horizontally mounted.

Items:

	// Vertical Tablets
	Switch	Bedroom_Mode_Switch				"Upstairs Bedroom Mode [MAP(screen_dark_bright.map):%s]"			(HomeState, Group_HabPanel_Dashboard)		[ "Switchable" ]
	String	habpanelEx_Bedroom_V			"[%s]"																(HomeState, Group_HabPanel_Dashboard)

	Switch	Theater_Mode_Switch				"Basement Theater Mode [MAP(screen_dark_bright.map):%s]"			(HomeState, Group_HabPanel_Dashboard)		[ "Switchable" ]
	String	habpanelEx_Basement_V			"[%s]"																(HomeState, Group_HabPanel_Dashboard)

	// Horizontal Tablet
	Switch	LivingRoom_Mode_Switch			"Livingroom Mode [MAP(screen_dark_bright.map):%s]"					(HomeState, Group_HabPanel_Dashboard)		[ "Switchable" ]
	String	habpanelEx_Livingroom_H			"[%s]"																(HomeState, Group_HabPanel_Dashboard)

Rules:

In Startup

	// Setting Screen Saver Item Values 

	habpanelExConfig.postUpdate('{"config_item":"habpanelExConfig","initComplete":true,"isShowInDrawer":true,"screensaver":{"isEnabled":false,"timeoutSeconds":300,"dashboardList":"","durationSeconds":300,"isFullScreen":true},"theaterMode":{"isEnabled":true,"isOn":false,"color":"rgba(0,0,0,0.90)","triggeringItem":null},"panelConfigItem":"habpanelExConfig"}') 
	habpanelEx_Bedroom_V.postUpdate('{"config_item":"habpanelExConfig","initComplete":true,"isShowInDrawer":true,"screensaver":{"isEnabled":true,"timeoutSeconds":300,"dashboardList":"Basement-Vertical,Garage-Vertical,MainFloor-Vertical,Cameras-Vertical,Covid19-Vertical","durationSeconds":120,"isFullScreen":true},"theaterMode":{"isEnabled":true,"isOn":false,"color":"rgba(0,0,0,0.90)","triggeringItem":"Bedroom_Mode_Switch"},"panelConfigItem":"habpanelEx_Bedroom_V"}')		
	habpanelEx_Basement_V.postUpdate('{"config_item":"habpanelExConfig","initComplete":true,"isShowInDrawer":true,"screensaver":{"isEnabled":true,"timeoutSeconds":310,"dashboardList":"Basement-Vertical,Garage-Vertical,MainFloor-Vertical,Cameras-Vertical,Covid19-Vertical","durationSeconds":130,"isFullScreen":true},"theaterMode":{"isEnabled":true,"isOn":false,"color":"rgba(0,0,0,0.90)","triggeringItem":"Theater_Mode_Switch"},"panelConfigItem":"habpanelEx_Basement_V"}')		
	habpanelEx_Livingroom_H.postUpdate('{"config_item":"habpanelExConfig","initComplete":true,"isShowInDrawer":true,"screensaver":{"isEnabled":true,"timeoutSeconds":320,"dashboardList":"Our House,Cameras,Up Stairs,Basement,Loft,Garage,RainViewer,Stocks,Covid19","durationSeconds":140,"isFullScreen":true},"theaterMode":{"isEnabled":true,"isOn":false,"color":"rgba(0,0,0,0.90)","triggeringItem":"LivingRoom_Mode_Switch"},"panelConfigItem":"habpanelEx_Livingroom_H"}')

In Events:

			// Turn Tablet Bright in Basement
			Theater_Mode_Switch.postUpdate(OFF)
				Thread::sleep(1500)  
			Theater_Mode_Switch.postUpdate(OFF)


			// Turn Tablet Dim in Basement
			Theater_Mode_Switch.postUpdate(ON)
				Thread::sleep(1500)  
			Theater_Mode_Switch.postUpdate(ON)

The OH server really has nothing to do with the HabPanelEx plug-in. It’s strictly at the client side that is driven by item values. You have to go to the tablet (client) and configure HabPanelEx which it will get cached in the browser settings after you set it up.

Best, Jay

1 Like

Wow nice did not think you could push these from the server - that is exactly what I was looking for… I’m not familiar with startup where do you write these rules?

You have to create a rule that is triggered by the event ‘System started’ This is done in a .rules file. OH has lot to offer and it can get complex and overwhelming very quickly. If you are new to OH I would suggest you take some time to read through the tutorials and examples. There is a ton of good info there and you can learn a lot by following and building off others example.

rule "Onstartup"
when
    System started
then  
...
    
end

I’ve written bunch of rules but did not come across the “system started” event. And there is something else you might be able to confirm with the habpanelExConfig:

  • most elements in the panel seem to be persisted on the server but I guess this specific one is only cached on the client (and loaded from server habpanelExConfig string item)?
  • could I just persist that value to the database instead of having it in “system started” rule to make sure it doesn’t get reset after rebooting my server?

Thanks

Erik

I don’t think persistence alone will work, although I haven’t explicitly tested it. In my setup I do have it persisted, but I don’t think my iPads retain their settings through a restart without the startup event initialization. However it has been some time, over a year ago, since I implemented my setup. It is certainly something you could try and report back if it works. BTW I wasn’t trying to insult you or belittle your expertise. It’s just that Tutorials and Examples is an often overlooked resource, even by experienced users. If I offended you I apologize.

1 Like

Correct. If you clear the cache in the browser on the client, you’ll have to reload it manually at the client again within HabPanelEx panel config.

Best, Jay

no offence taken at all, I really appreciate all the help and feedback here and there is always more to learn from tutorials and examples :slight_smile:

Anyway, going to try setting up a persistence on this value and see if that works - this could be an option with almost no code.

Ok so no luck with persistence - haven’t checked the sqlite db content but the group was supposed to be persisted. Also another thing I figured out is that I need to have the browser open on the habpanelex to enable the screen saver. If my initial URL is any of the other panels then the screen saver never kicks in.

Hi together,
I just found this extension for HabPanel and tried to install it. Unfortunately I only get a blank widget without showing any of the configuration possibilities.

Does anybody know if HabPanelEx works also with openHAB 3.0 or might this be the issue?

1 Like

I’m having the same issue (OH3.1)

Followed the instructions. Just getting a blank panel.

1 Like