Plugin: AutoVirtualThermostat (AVT)

[quote=“Forzaalfa, post:120, topic:198289”][quote=“Forzaalfa, post:118, topic:198289”]Mail sent!

New issue, I tried to get the Imperihome up and running. After putting in the link in the ‘local’ parameter, I get “System found, Unable to connect”.

If i run the link in chrome (on a PC) it returns an empty page… Any ideas?[/quote]

I got the imperihome integration to work. Not sure if you changed anything, or if it was the change to 5ghz wifi instead of 2.4ghz that did it? Didnt think that would matter, but now it works at least. :)[/quote]

Nope, no changes. Happy to hear it’s working out, if not a bit mysteriously.

What is the best way to add a second AVT device in ALTUI please?

+Create device – use D_AutoVirtualThermostat1.xml and I_AutoVirtualThermostat1.xml

I just set up a Home Assistant controller to check it out, and to try connecting google home. This worked very well, and i was suprised to see the virtual thermostats going over as well. (well, not the eco/comfort button)

I do however notice that the “current setpoint” passed to HA is the “Cooling Setpoint”, not the “current setpoint”. Is that something the transfer script is doing, or might it be AVT deciding which one is reported?

I have no idea how the innards work here, just curious. :slight_smile: I’m considering lightening the load on the Vera by transferring some automation to HA, so this would be cool to get right. :slight_smile:

[quote=“Forzaalfa, post:124, topic:198289”]I just set up a Home Assistant controller to check it out, and to try connecting google home. This worked very well, and i was suprised to see the virtual thermostats going over as well. (well, not the eco/comfort button)

I do however notice that the “current setpoint” passed to HA is the “Cooling Setpoint”, not the “current setpoint”. Is that something the transfer script is doing, or might it be AVT deciding which one is reported?

I have no idea how the innards work here, just curious. :slight_smile: I’m considering lightening the load on the Vera by transferring some automation to HA, so this would be cool to get right. :)[/quote]

Thermostats are, IMO, something Vera didn’t think through very well, made some mistakes, and it seems painted themselves into a corner that they’re now a bit stuck with. Short version: between Vera/Luup and pyvera, it’s broken for all thermostats and not likely to be fixed in the near future. I’ve been party to some discussions about this on the pyvera side, but I’m not engaging the problem with code at this point because I feel it’s part of bigger architectural problem in pyvera, and that makes me shy away from choosing HA as anything much more than a casual UI in a Vera environment. If you want some details with a healthy dose of opinion and sarcasm, you can read on. Otherwise, sum it up this way: both ends of that connection are at fault.

The gory details:

On the Vera side, the TemperatureSetpoint1 service (a UPnP standard service) supports both cooling and heating setpoints, but does so in a two step process. It is first necessary to do a SetApplication action to tell the service what mode to be in (“Heating” or “Cooling”). The SetCurrentSetpoint action then sets the setpoint for that mode. The CurrentSetpoint state variable returns the setpoint of the current mode, whatever it may be, and it changes when you change the Application.

I guess Vera couldn’t figure out how to make a two-step process like this work in UIx when a thermostat has both heating and cooling setpoints (the static JSON can pass multiple parameters, but it can’t do a multi-action action like this, although it would not have been hard to implement). So they kludged the TemperatureSetpoint1 service into two aliased services called TemperatureSetpoint1_Heat and TemperatureSetpoint1_Cool. Which setpoint gets set is determined by which service you use when doing a SetCurrentSetpoint action.

The problem they create for themselves by doing this is they are not two separate service definitions, they are just two aliases that point to the same service definition (S_TemperatureSetpoint1.xml). The service definition sets the “shortcode” for various state variables, and in this service definition, the CurrentSetpoint state variable receives the shortcode “setpoint”. The problem, though, is that while state variables are separated by service Id, shortcodes are not–the shortcode must be unique per device, so you can’t set “setpoint” twice in the structure (HA uses lu_sdata) for the same device. But it’s trying, because of the way Vera is going it, but the result is what whichever service sets shortcode in the structure second wins. So it’s only possible for HA to get ONE of the two setpoints out of sdata, and that’s probably why you’re getting the cooling value (it could have just as randomly/likely been heating, I suppose).

Apparently Vera worked around this problem by… adding ANOTHER STATE VARIABLE! They added the AllSetpoints state variable to the TemperatureSensor1 service, which contains ALL THREE setpoints (yes, three): heating, cooling, and auto. Without diving into why that seems wrong, they made a more egregious mis-step #3: they didn’t modify the service definition to include this new variable–it’s undeclared. They just set the variable using the service (Luup allows this freely). And because they didn’t declare it in the service, there is no shortcode for it, and it doesn’t appear in sdata where HA or anything else that uses sdata could grab it.

Thermostats are a soup sandwich, IMO. When you start looking at the UI code to see how they implement the interfaces, it gets even worse. Couple that with a few bugs like a random change to the CSS for the spinner_horizontal controls (used as setpoint buttons in thermostats, and by other plugins for other types as well, which is why the buttons are currently appearance-broken as of 7.0.23 or so), and it’s a frustrating hot mess.

Unfortunately, for HA it means that the underlying subsystem, pyvera, is going to need some wool-pulling. And this gets to where pyvera has what I think is a big problem: the subscription service in pyvera relies entirely on sdata, so the majority of devices see only the data exposed by sdata (shortcodes), and not the full state of the device (which it could get from a status request). Pyvera does use status requests, but not as the subscription notice object target, and apparently HA in turn uses those “lesser” objects almost entirely, so HA probably doesn’t even really know what it’s missing. Of late, the door lock object in pyvera has been modified to address some of its shortcomings that could not be addressed by sdata alone, and there are rumblings around thermostats as I write this. But IMO, the problem extends to every object and should be approached as a subsystem-wide problem, not a per-object problem, and pyvera needs a big redo to use status requests rather than sdata, so it has a more complete picture of the device state to use in building more comprehensive and correct data representations of the Vera objects. The consequence of that may be breaking for pyvera’s clients, including HA, and from what I’ve seen, HA freely publishes breaking changes for its users, but takes a dim view of its dependent subsystems doing the same thing to it.

So, I view pyvera as a minimalist interface in HA’s use, and likely will be for a very long time. For this reason, I don’t view Vera+HA as anything more than a better, more convenient UI for the stuff that works, and I ignore the rest. There was a time I moved a lot of my automations there, but I’m now moving them back. Knowing what I now know, I don’t see the Vera+HA combination as a serious long-term strategy.

Seems like there is some points here for both pyvera and ezlo gang to look into. I totally get your frustration here when there is seemingly obvious better ways to do stuff, and they just decided not to. ::slight_smile:

Very interesting to read about the Vera/HA issues, I mainly wanted the HA to get the interfaces vera is missing (Home, Xiaomi, Wifi switches, etc… ), on the automation side Vera is far simpler to set up thanks to your apps (Delaylight, Reactor and AVT)… HA doesnt seem to have any equivalents with a GUI at all…

Going off the AVT topic here, so i’ll stop with the conclusion that this is not AVTs fault. :slight_smile:

You’re probably mostly busy with Reactor stuff, but if you feel like looking at having multiple stages on heating that would be lovely! :slight_smile:
This may not be an issue where you live, but in norway we need more ovens when winter sets in hard…:wink:
Mabye something could look at the heat progression and - say - turn on one more oven if the temperature hasn’t risen after 10 minutes? or mabye control it by looking at outside temperature value/difference?

I’m currently using reactor to turn on more ovens if the outside temp is below a certain level, it works fine… Mabye some way to look at reaction progression over time is something to integrate in reactor?

Just throwing out some ideas… :slight_smile:

Reactor is settling down, and I’m just getting off a PID project in another world I work in. Stay tuned.

I am reading the documentation for this plugin with great interest as it is doing a portion of what I am looking to do. I am thinking about adding a few things to it: control of HVAC vents like the econet zwave vents and the keen zigbee vents, a ventilation only mode (to equilibrate temperature between two floors of a house) and a motion sensor to determine which temperature sensors to take into consideration for the ambient temperature calculation. I was thinking about doing this all through scenes but maybe AVT could be a good base for it…

I will think about this as I travel and touch base with you next week.

Sounds good! No rush… I am also travelling this week.

@rigpapa, if you are back, this is the logic I am proposing in an excel file for a thermostat plugin enhancement.
I could pretty much do all of it through scene lua codes but I think a plugin would benefit the community and would be scalable. I am also sure you would write it much better than I would.

@rigpapa: Any feedback, question, suggestions?

Is this of interest to you to implement as part of AVT? If not I think I will just write some custom device/code and scenes to make it work for my specific setup but I was hoping this could be shared with others.

Sorry, I’ve had a busy few days since getting back from a trip, and I want to give this its proper due diligence before I respond. It seems pretty specialized, but sit tight, I want to make sure I’ve read it completely and understood it.

Thank you for looking into it. It can indeed look pretty involved. What I am trying to get to is to reproduce a combination of what the ecobee thermostat and the keen vent hub do all into one system.

By the way, what are “up vents” and “down vents”?

Ahh I knew I had some unclear jargon in there.

The idea is for a two story house having a temperature delta issue between the two floors.
The Up vents are the vents for the upper floor. The Down vents are the ones downstairs. This is an optional idea to save energy when some thermostat could just recycle air from up and down the house instead of turning on heat or AC.

By the way the vents are devices which I have implemented with as a window covering but with a custom device.json called D_Vent1.json which I have shared in the Keen vent thread. I have been using the same file for both zigbee and zwave vents.

Just so you know I actually started writing the code which could be the basis for a plugin. I am actually almost done. The big task ahead is to be able to setup the device json to input all the different sensors and vents as they are currently hardcoded for my setup. It isn’t as difficult as I anticipated.

I think you should continue in this direction. The contents of your spreadsheet points to some very specific configuration for your setup. While I know you can generalize it, even so, it appears to be a bit more than a plugin that advertises itself as a “virtual thermostat” really demands.

Thanks, I understand. It is a holistic HVAC control making use of the “room” feature of vera where I make use of several data source within the room:
-windows opened/closed
-vents if they are controlled (only relevant for forced HVAC air setups)
-temperature sensors if they are present
-motion sensors

I am done the lua portion. Will work on the UI device portion next. This might become a different plugin altogether.