HABPanel widget: Virtual Thermostat/OnOff Appliance scheduling

Tags: #<Tag:0x00007faed98fe848>

IT WORKS!
Because I already have InfluxDB installed to graph some variables (https://guiott.com/?page_id=2828) it was enough to add this line in the influxdb.persist:

HVAC_Mode, HVAC_Schedule : strategy = everyChange, restoreOnStartup

Hoping to help someone else, I’m keeping to share my small steps here. Please let me know if it could be useful. That’s still very raw but it works.
After the layout changes, I’ve added a check on the Thermostat version of the rule to perform an action when the temperature is outside a desired range, considering an hysteresis to define the comfort range where the heater/cooler is off. It avoids too frequent switches of the system.

The status of the system is reflected by the color of the knobs bars:
RED (HOT) = actual temperature is over the setpoint plus hysteresis
GREEN (COMFORT) = actual temperature is within comfort range
BLUE (COLD) = actual temperature is below the setpoint minus hysteresis

to do that something changed on ohscheduler.tpl.html and on ohscheduler.css.
The actions are on the rule “Thermostat Action” in the OHSchedulerHVAC.rules file.
It needs a further item for each gauge requiring a slight change in the widget configuration.
The knobs bars color is managed by the setKnobColor() function in
ohscheduler.js file.

The whole package can be retrieved here:
https://guiott.com/?attachment_id=3160
this is just a little add-on to the great original job from Geo.

Any comment is welcome.

1 Like

Hi, firstly can I say I think this widget is brilliant, exactly what I was looking for. I have a small issue that I was hoping somebody may have seen before… Its the dials, for some reason my dials are displaying “in reverse”. So the colours are showing to the left for some reason and then when I try adjust a target temperature it then tries to jump to the right and it gets messy… I also can’t seem to very get to a target of zero… mine seems to stop at 18… really odd, as far as i can tell everything is working fine aside from that. I am getting events come through and the schedule changes register just fine.

… I did a bit of playing about with values… seems the problem manifests when you set the temp min to anything less than 1… not had time to work out why thats the case but thats at least how to reproduce it.

thanks
Paul

1 Like

Hi, very nice job !! This is much better than mine :slight_smile:
I am testing the use in these day and making some css changes to fit to my habpanel.

I am using the HVAC Scheduler as follow:
with HVAC Mode = Auto the HVAC_Target_Temp change following the next scheduling
with HVAC Mode = Manual the HVAC_Target_Temp is set according to the Knob widget manually

Now, moving from Manual to Auto mode the HVAC_target_temp remain as it is until the next schedule.
I would like that on HVAC Mode changed to “AUTO” the HVAC_Target_Temp is immediatelly set to the last scheduled temperature.

I will try to write a sample:

Suppose my schedule are Sun at 12:00 T=21°C and Sun at 22:00 T=18°C
It is Sun at 19:00, I was out and I set Manual mode with T=17°C, I came back home and I set Auto Mode:
Until 22:00 the Temp set remain 17°C, while I want it immediatelly set to 21°C.

My problem is how to calculate the “last scheduled temperature” … Do you have any idea where I can start calculating the last scheduled temperature?

Regards
Lorenzo

this this out as well on OH2.4
however i have implemented only OnOff commands,
i was able to show and control manually light, however the schedule doesnt seems to work.
the onOff mode, and onoff schedule items set sucessfully,
i have implemented a schedule for certain amount of time, however nothing is fired.

logs shows when setting schedule/Manual or adding new schedule - the relevant strings mare updates:
OnOff_Mode
OnOff_Schedule
i added logInfo to the Strings - and they are updated fine:
10:03:00.001 [INFO ] [cript.update fired for scheduled rule] - update fired for scheduled rule 10:03:00.002 [INFO ] [.smarthome.model.script.onoffmode is:] - SCHEDULE 10:03:00.003 [INFO ] [thome.model.script.onOff Schedule is:] - {"CorridorDimmer_CorridorLight":{"D1":{"T1005":5}}} 10:03:00.003 [INFO ] [smarthome.model.script.OnOff Next is:] - NULL 10:03:00.004 [INFO ] [marthome.model.script.OnOff queue is:] - NULL

on 10:05 - the switch didnt turned on for 5 minutes…

cron seems to run fine.

any idea?

EDIT: Found the problem - forgot to add grpOnOff to the switch i control…
now everything seems to work fine

Hello @nepotu

Thank you for taking the time to create this amazing timeline widget.

It took me a little while to get my heat around the basics, but it’s certainly working for me now.

One tiny thought occured to me, Is it possible to add different states to the OnOff scheduler?

For example, if I wanted to use a colour picker or dimmer, it would be great if I could choose the colour or % for the ON command.

I did add different Mode options, but I don’t really understand if that field refers to the mode of the scheduler, or the operational Mode of the Item.

for example, I tried

["OFF","ON","0,100,100","250,100,100"]

My use case is for a colour picker and dimmer in a living room.

So that I can set different dim levels or colours in the room with your scheduler.

Thanks again,

Stuart

UPDATE…

A couple of hours after posting this, I’ve thought of another use case…

It would be great to be able to schedule a radio channel change…

ANYTHING to automatically avoid a certain DJ at 2pm…

Or 9am on a Sunday

Great work!

I would like to use the “modified” widget from guiott, but somehow I didn’t get it to work as I want:

Topic 1

I tried to switch to german by modifing ohscheduler.js but this doesn’t change the language ?

Is there another way which I missed ?

Topic 2
There is only the button AGGIUNGI and not two, corresponding to ADD/DELETE

One Problem solved! I’ve to clear the browser cache :slight_smile:

now it looks fine:

Still missing the “button” for update/delete

any ideas, where to look ?

Hello everyone! For the past couple of months I had no spare time to continue the work on this widget or to assist those in need. Things will not change anytime soon, therefore you will have to rely on self study/trial and error.

@ All sorry for the delayed reply. I assume that most of you have already figured everything out until now.

@pmbsa The values appear in reverse because they are below the minimum value (18 if IIRC).

@Foxejoe The target temperature value will not change when the mode changes. The rule file initiates the target temperature (looks at the previous scheduled value) in the case it is not yet set. You have to change the rule in order to achieve what you desire. Look for “// [fail-safe] Init target temperature if not set” and change the condition in the if statement or add the below block after it (haven’t tested this, but it should work, unless there is something wrong in the syntax).

if (prevVal !== null && HVAC_Mode.state == 'AUTO') {
    logInfo('temperature-control.rules', 'Target temperature for item ' + targetItem.name + ' set to : ' + prevVal)
    targetItem.postUpdate(prevVal)
}

@MDAR The Modes switch allows you how to run the automation (e.g. use a schedule to control the temperature or when to start some appliance for a defined amount of time). What you want to achieve implies lots of changes in all the files (widget and rules) because you need a 3rd mode (currently this widget supports OnOff appliances and Thermostat schedules) that will allow you to set additional “variables” in your schedule item (e.g. something similar to OnOff mode, but with another option to set the intensity/color).

@tarabas the Update/Delete option appears when you edit items from your schedule (double click on the values from Zeitplan tab). For this you will need to first add something in the schedule.

PS1: haven’t tested this with OH 2.4, hence I cannot guarantee it will work without some code changes.

PS2: I have posted the code to GitHub, hoping there will be someone more experienced to continue the work on this widget.

1 Like

Hi -maybe somebody can help wih that:
Schedule is not working and there is erroe in log:
2019-03-17 21:40:00.353 [INFO ] [ome.model.script.onoff-control.rules] - OnOff Appliances control error: java.lang.ArrayIndexOutOfBoundsException: 1

Any Idea with this issue?

Just tested and it seems working like a charme …
Thanks

Hello all, and THANK YOU @nepotu for developing this!

I feel like this could become something really important for the OH community(it certainly feels a void for me,I even considered nodeRED + bigtimer as i don’t use google calendar and hence caldav doesn’t suit me + well, google calendar is yet another cloud service).

I’ve installed your “widget” (it’s reductive to call it that, as there are so many components involved) and got it to work “as expected”(which is in and of itself testament to the quality of your work)

I am in the process of trying to adapt your “widget” to my needs, but i am nowehere near your level of understanding of programming, hence - I have a number of questions… and i guess some will feel funny to the more expert peeps amogst you.

-Items file: You have included["tags"] for each item, but they aren’t in the format used for alexa or google home integration. Are these tags there just as example or do they get used by some of the code i’m failing to locate (at the very least they aren’t mentioned in the rules)

-themes and colors some clever people like @guiott already had the knowledge needed to adapt the colors and themes, but I… well I’ve learned the little i know trying to use rules dsl for OH to do what i want it to do (so far with good success), while here we enter a space i’m not familiar with.
I’ve applied the Matrix Theme for HABPanel to my habpanel but your scheduler doesn’t fall in line with the rest.
Could you jot down a quick guide in regards to how to modify colors?
OR/AND Could you point me towards what resources to study in order to gain the knowledge needed to make those changes, so that maybe contribute in some way…

-VS ide with OH extension installed points to quite a high number of problems in the rules i copypasted from your github project, but then OH is able to refresh them and they work just fine.
So far i’ve made a point of not having one problem in my rules…
I’m guessing that is because you are using syntax coming from Java and not strictly xtend - is that it? or is the language service just not advanced enough for such advanced code and instead meant for beginners like myself?

Lastly, i wish this project would become a staple of OH, i feel it certainly deserves attention.
thanks again!

I have installed the software as instructed in the original post/GitHub site. Installing the files into the html, items, and rules directories.

I also installed JSONPath Transformation (using PaperUI interface).

Contents of items/OHScheduler.items:

// These are unchanged from original file
Group       grpTemp
Group       grpTargetTemp
String      HVAC_Mode              "HVAC Mode [%s]"                       <switch>                              ["HVACMode"]
String      HVAC_Schedule          "HVAC Schedule [%s]"                   <calendar>                            ["HVACSchedule"]
String      HVAC_Queue             "HVAC Queue [%s]"                                                            ["HVACQueue"]            
DateTime    HVAC_Next_Change_Time  "HVAC Next Change Time [%1$ta %1$tR]"  <calendar>                            ["HVACNextChange"]

// These items I added, because the lines are so long, I removed most of the channel details
Number      HVAC_SetpointHeating_Temp         "Setpoint Heating Temp [%.0f °F]"            <temperature> (grpTemp)               ["SPHeatTemp"]        {channel="zwave:device:..."}
Number      HVAC_SetpointHeating_Target_Temp  "Setpoint Heating Target Temp [%.0f °F]"     <temperature> (grpTemp,grpTargetTemp) ["SPHeatTargetTemp"]  {channel="zwave:device:..."}
Number      HVAC_SetpointCooling_Temp         "Setpoint Cooling Temp [%.0f °F]"            <temperature> (grpTemp)               ["SPCoolTemp"]        {channel="zwave:device:..."}
Number      HVAC_SetpointCooling_Target_Temp  "Setpoint Cooling Target Temp [%.0f °F]"     <temperature> (grpTemp,grpTargetTemp) ["SPCoolTargetTemp"]  {channel="zwave:device:..."}

Then I installed the widget on a HABPanel dashboard.

What works:

  • When I set manually set the temperature I want, ex: 77 degrees F, using the widget knob, the temperature on my thermostat changes.

What does not work:

  • When I set the schedule to change the temperature, ex: at 1200 change temp to 70 degrees F. At 1200 the knob says “Set to 70 F” but there is no change to the actualy temperature settings.

My only clue is in the event logs, which says the following.

Manually changing the temperature (works).

[ome.event.ItemCommandEvent] - Item 'HVAC_SetpointHeating_Target_Temp' received command 77
[nt.ItemStatePredictedEvent] - HVAC_SetpointHeating_Target_Temp predicted to become 77
[vent.ItemStateChangedEvent] - HVAC_SetpointHeating_Target_Temp changed from 67 to 77

Setting a schedule to change the temperature. First three lines are setting the temperature at a time X. Then time X is reached, I’ve added a comment. And the temperature is suppose to change. If it matters, the Mode is set to “Heat”.

[ome.event.ItemCommandEvent] - Item 'HVAC_Schedule' received command {"HVAC_SetpointHeating_Target_Temp":{"D5":{"T0955":70}}}
[vent.ItemStateChangedEvent] - HVAC_Schedule changed from NULL to {"HVAC_SetpointHeating_Target_Temp":{"D5":{"T0955":70}}}
[vent.ItemStateChangedEvent] - HVAC_Next_Change_Time changed from NULL to 2019-07-05T09:55:00.000-0500
// --Time X occurs here--
[vent.ItemStateChangedEvent] - HVAC_Queue changed from NULL to HVAC_SetpointHeating_Target_Temp=70
[vent.ItemStateChangedEvent] - HVAC_SetpointHeating_Target_Temp changed from 77 to 70
[vent.ItemStateChangedEvent] - HVAC_Queue changed from HVAC_SetpointHeating_Target_Temp=70 to 
[vent.ItemStateChangedEvent] - HVAC_Queue changed from  to HVAC_SetpointHeating_Target_Temp=70
[vent.ItemStateChangedEvent] - HVAC_Queue changed from HVAC_SetpointHeating_Target_Temp=70 to 
[vent.ItemStateChangedEvent] - HVAC_Queue changed from  to HVAC_SetpointHeating_Target_Temp=70
[vent.ItemStateChangedEvent] - HVAC_Queue changed from HVAC_SetpointHeating_Target_Temp=70 to 

What I notice is that the HVAC_Queue is not correctly being set. I feel there should be something after the “to”.

Can someone help point out what is happening? And why the scheduler does not change the target temperature correctly?

Is there is a way to debug the rules file (by dumping more output to the logs)?

Edit: version of Openhab2 is 2.4.0

Solved - The problem was in the rules. The code that Geo @nepotu generously shared with us uses postUpdate() to change the temperature. I hacked the rules to use sendCommand(). I suspect this is a function of my Z-wave thermostat and how to control it. Additionally, I only have two items now: a heating and cooling setpoint. I no longer have both a ‘temperature’ and a ‘target temperature’.