Plugwise has a service for climate.set_hvac_mode, but it doesn’t have any service to change the active schedule. The documentation mentions an awkward way to do it (Plugwise - Home Assistant) but this can not be used in automations.
Since it can be done remotely, I assume the issue is not in the api or the plugwise python component, but simply that it hasn’t been implemented yet. Looking at the source I can’t figure out how to do it via the api though (there only seems to be a ‘get’ for the schedules).
At the moment only the active schedule can be turned off and on, and the previously active schedule can be turned on.
I have been thinking of adding this feature (fellow code-owner of Core plugwise / plugwise-beta ) but there is nothing in the User Interface that can use this feature.
It could be done via a service call but then the user would need to input the Schedule name. That makes it unnecessarily complex in my mind.
It is now also possible to create an automatically filled input_select (not sure if it is called that when it is provided by an integration, maybe just select?). In the attributes right now is all the available names isn’t there? So it would be possible to create an extra entity as well.
I also don’t think it is that big a deal that it needs a valid name, there’s many service calls that don’t work if you put in the wrong data. As an MVP at least all that is needed is the possibility to set the schedule via the api I guess, the rest can follow (and I can possibly write my own PR for).
[edit] Looks like it is indeed select, here’s an example for the logitech harmony integration.:
A quick look at the python plugwise code I came to the same conclusion. I noticed the following functions:
async def set_schedule_state(self, loc_id: str, name: str, state: str) -> bool:
"""Set the Schedule, with the given name, on the relevant Thermostat.
Determined from - DOMAIN_OBJECTS.
"""
and
def _schemas(self, location: str) -> tuple[str, ...]:
"""Helper-function for smile.py: _device_data_climate().
Obtain the available schemas/schedules. Adam: a schedule can be connected to more than one location.
NEW: when a location_id is present then the schedule is active. Valid for both Adam and non-legacy Anna.
"""
This last one appears to be used when the device list is filled (since the underscore implies I assume that it shouldn’t be used directly).
So that leaves the question on how best to implement it. a select entity is probably the easiest (I think I might be able to figure it out), but the documentation Tom linked does say the following:
This entity should only be used in cases there is no better fitting option available. For example, a bulb can have user selectable light effects. While that could be done using this select entity, it should really be part of the light entity, which already supports light effects.
That sortof implies that it should first be included in the climate entity and then added to the plugwise integration? Just adding a select seems like a lot less of a hassle though.
You are looking at the wrong code. The service will need to be implemented in the plugwise-beta or the Core plugwise code. That code will call the necessary function(s) from the plugwise-library code that you show above. I think Tom has planned to try building something during the coming day(s).
I think there’s some confusion, I realise that it needs to be done on the integration side, I just wanted to double-check that these functions in the package were the correct ones, since the integration will have to call these functions won’t they?
Yes, the first function will be needed. But not the 2nd. The list of available schedules is in the output of the plugwise backend. Look at plugwise-beta climate.py line 144 on how to find them.
wow, that was fast
Do I understand correctly that I can test it by temporarily installing the beta integration via HACS, or do I need to delete the core version for that?
No, when you install the Plugwise-beta custom_component it overrides the Core Plugwise component.
There are 100% compatible, when both have the same code-base.
This test-version was made specifically for you and another user who requested the changes.
It was already tested by Tom and me.
But more people should test before we merge the changes into the plugwise-beta main branch.
Preferably the requester(s) of the changes.