Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make hvacThermostat weekly_schedule more user friendly #5535

Merged
merged 4 commits into from
Mar 4, 2023

Conversation

sjorge
Copy link
Contributor

@sjorge sjorge commented Mar 1, 2023

Took a while to figure out how this works, did I miss a piece of documentation somewhere?

I also made it more user friendly, before you had to write this:

mosquitto_pub -t zigbee2mqtt/trv/office/set -m '{"weekly_schedule":{"dayofweek":1,"mode":1,"numoftrans":5,"transitions":[{"heatSetpoint":16,"transitionTime":0},{"heatSetpoint":22,"transitionTime":390},{"heatSetpoint":18,"transitionTime":540},{"heatSetpoint":22,"transitionTime":1200},{"heatSetpoint":16,"transitionTime":1320}]}}'

Now you can also (this is backwards compatible) write:

mosquitto_pub -t zigbee2mqtt/trv/office/set -m '{"weekly_schedule":{"dayofweek":"monday","mode":"heat","numoftrans":5,"transitions":[{"heatSetpoint":16,"transitionTime":"00:00"},{"heatSetpoint":22,"transitionTime":"06:30"},{"heatSetpoint":18,"transitionTime":"09:00"},{"heatSetpoint":22,"transitionTime":"20:00"},{"heatSetpoint":16,"transitionTime":"22:00"}]}}'

Which to me is a lot more readable and easier, no more doing minutes since 00:00 calculations for transitionTime, no more wondering if sunday is 0 or 7 for dayofweek, ...

@sjorge
Copy link
Contributor Author

sjorge commented Mar 1, 2023

@Koenkk actually hold off with merging, I've been reading some more in the ZCL and seems dayOfWeek is a bitmask
So you can set it for multiple days, I'll refactor this to take something like.

mosquitto_pub -t zigbee2mqtt/trv/office/set -m '{"weekly_schedule":{"dayofweek":["monday"m "tuesday"],"mode":"heat","numoftrans":5,"transitions":[{"heatSetpoint":16,"transitionTime":"00:00"},{"heatSetpoint":22,"transitionTime":"06:30"},{"heatSetpoint":18,"transitionTime":"09:00"},{"heatSetpoint":22,"transitionTime":"20:00"},{"heatSetpoint":16,"transitionTime":"22:00"}]}}'

But I don't have more time today

For self reference
Screenshot 2023-03-02 at 10 24 29
Screenshot 2023-03-02 at 10 24 56

@sjorge sjorge changed the title Make hvacThermostat weekly_schedule more user friendly [WIP] Make hvacThermostat weekly_schedule more user friendly Mar 1, 2023
@sjorge
Copy link
Contributor Author

sjorge commented Mar 3, 2023

Alright, I got it all fixed and retested. The following now works:

mosquitto_pub -t zigbee2mqtt/trv/office/set -m '{"weekly_schedule":{"dayofweek":["monday","tuesday","wednesday","thursday","friday"],"mode":"heat","numoftrans":5,"transitions":[{"transitionTime":"00:00","heatSetpoint":16},{"transitionTime":"06:30","heatSetpoint":20},{"transitionTime":"07:30","heatSetpoint":18},{"transitionTime":"18:00","heatSetpoint":20},{"transitionTime":"22:00","heatSetpoint":16}]}}'
mosquitto_pub -t zigbee2mqtt/trv/office/set -m '{"weekly_schedule":{"dayofweek":["saturday","sunday"],"mode":"heat","numoftrans":3,"transitions":[{"transitionTime":"00:00","heatSetpoint":16},{"transitionTime":"09:00","heatSetpoint":20},{"transitionTime":"22:00","heatSetpoint":16}]}}'

This sets a different schedule for weekdays and for the weekend on my TRV.

You can also do something like:

mosquitto_pub -t zigbee2mqtt/trv/office/set -m '{{"weekly_schedule":{"dayofweek":["saturday","sunday"],"mode":["heat","cool"],"numoftrans":3,"transitions":[{"transitionTime":"00:00","heatSetpoint":16},{"transitionTime":"09:00","heatSetpoint":20},{"transitionTime":"22:00","heatSetpoint":16}]}}'

I could not test the above as all my thermostats/trv's are heating only. But the mode field gets correctly set according to the ZCL.

@sjorge sjorge changed the title [WIP] Make hvacThermostat weekly_schedule more user friendly Make hvacThermostat weekly_schedule more user friendly Mar 3, 2023
@sjorge
Copy link
Contributor Author

sjorge commented Mar 3, 2023

Once this gets merged, I think we should add a 'generic' page somewhere on zigbee2mqtt.io about how to write a thermostat schedule payload.

@Koenkk
Copy link
Owner

Koenkk commented Mar 4, 2023

@sjorge preferably an expose is added such that this can be configured from the frontend. An example can be found here:

exposes.list('schedule', ea.STATE_SET, exposes.composite('dayTime', 'dayTime', exposes.access.STATE_SET)

@sjorge
Copy link
Contributor Author

sjorge commented Mar 4, 2023

That one does not look to match the hvac one at all.

Although this commits should make it easier to add something.

However you can execute it multiple times and it does partial updates on the device as described in the ZCL.

If this turns out to be complex, i still think this is a big improvement even without an exposes value.

But I will see if I can add something.

@Koenkk
Copy link
Owner

Koenkk commented Mar 4, 2023

This can already be merged indeed, thanks!

@Koenkk Koenkk merged commit 4921399 into Koenkk:master Mar 4, 2023
@sjorge sjorge deleted the thermostat_schedule branch March 4, 2023 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants