Python Plugin: Thermostat Weekly Scheduler

Python and python framework

Moderator: leecollings

Post Reply
ArtBern
Posts: 11
Joined: Monday 18 January 2021 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Python Plugin: Thermostat Weekly Scheduler

Post by ArtBern »

Hello, my county home is heated with electricity on multi tarif. There is only floor heating with electric boiler, so it takes about 20 hours to pre-heat house from +10C to + 21C during winter season.

Hot water is heated with another 100 litres electic boiler. It makes sence to pre-heat water at maximum power during low tarif hours and consume that reserve during high tarif hours.

Desired schedule can be configured with Domoticz timers and virtual thermostat. But manipulating and observing timers in table is nightmare.

So I developed plugin with UI to manipulate schedule on weekly manner.

https://github.com/ArtBern/Scheduler

Image
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by salopette »

Seems to be looking good, is there any guide on how to install it? Can you install this via the PlugIn manager?

https://github.com/stas-demydiuk/domoti ... ns-manager
ArtBern
Posts: 11
Joined: Monday 18 January 2021 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by ArtBern »

Created pull request to Plugin manager.

My plugin has dependency on python modules. Any chance to automate python module installation with Plugin manager ?

Module https://github.com/ArtBern/Domoticz-API can be installed with command:

sudo pip3 install git+git://github.com/ArtBern/Domoticz-API.git -t /usr/lib/python3.7
User avatar
waltervl
Posts: 5148
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by waltervl »

The readme states that it will create a Virtual thermostat. What can I do with this? How can I connect/Link this to my real life Thermostat widget I already have in Domoticz?

I also have several room thermostats in Domoticz. Can I have seperate schedules for seperate thermostats? Or do I have to create New Virtual Thermostat for each real life themostat?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
ArtBern
Posts: 11
Joined: Monday 18 January 2021 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by ArtBern »

At the moment there is no option to link with existing real thermostat device. Please provide me Device Type of your thermostat and I try to implement this.

Right now you can create Blocky (or other) script, so current SetPoint from virtual thermostat will be continuously copied to your existing Domoticz device.

You can create as many virtual thermostats as you need. I have one for water heating and another 2 for separate rooms. Each virtual thermostat requires separate Name and Port in hardware settings.
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by besix »

Hey
What am I missing?
Installation

Code: Select all

sudo pip3 install git + git: //github.com/ArtBern/Domoticz-API.git -t /usr/lib/python3.7

cd ~/domoticz/plugins
git clone https://github.com/ArtBern/Scheduler
sudo /etc/init.d/domoticz.sh restart
In the hardware I change the IP to domoticz IP and port to domoticz port
I get an error in the domoticz log
2021-01-19 12:16:57.892 Error: (Scheduler) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Scheduler/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'.
2021-01-19 12:16:57.892 Error: (shed) Module Import failed, exception: 'ModuleNotFoundError'
2021-01-19 12:16:57.892 Error: (shed) Module Import failed: ' Name: magic'
2021-01-19 12:16:57.892 Error: (shed) Error Line details not available.
Domoticz
Version: 2020.2 (build 12828)
Build Hash: 7a7c9645c-modified
Compile Date: 2021-01-07 10:21:19
dzVents Version: 3.1.1
Python Version: 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
ArtBern
Posts: 11
Joined: Monday 18 January 2021 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by ArtBern »

besix wrote: Tuesday 19 January 2021 12:26 Hey
What am I missing?
Installation
You need https://pypi.org/project/python-libmagic/

Code: Select all

sudo apt-get install libmagic-dev
sudo pip3 install python-libmagic
And next one:

Code: Select all

sudo pip3 install accept-types
Hope one day I remove dependencies and simplify installation.
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by besix »

Thanks for the help
There is progress, but I still have bugs

2021-01-19 13:31:59.539 Status: (Scheduler) Stop directive received.
2021-01-19 13:31:59.539 Status: (Scheduler) Exiting work loop.
2021-01-19 13:31:59.840 Status: (Scheduler) Stopping threads.
2021-01-19 13:31:59.840 Status: (Scheduler) Stopped.
2021-01-19 13:31:59.840 Status: (Scheduler) Started.
2021-01-19 13:32:01.009 (Scheduler) onStart called
2021-01-19 13:32:01.010 (Scheduler) Read file: /home/pi/domoticz/plugins/Scheduler/web/html/thermostat_schedule.html
2021-01-19 13:32:01.010 (Scheduler) Read file: /home/pi/domoticz/plugins/Scheduler/web/javascript/thermostat_schedule.js
2021-01-19 13:32:01.011 (Scheduler) Read file: /home/pi/domoticz/plugins/Scheduler/web/images/downArrow_white.png
2021-01-19 13:32:01.011 (Scheduler) Read file: /home/pi/domoticz/plugins/Scheduler/web/images/downArrow_red.png
2021-01-19 13:32:01.015 (Scheduler) File created: /home/pi/domoticz/www/templates/Scheduler-Scheduler.html
2021-01-19 13:32:01.015 (Scheduler) Domoticz-API server is: Server("localhost", "81"): False
2021-01-19 13:32:01.005 Status: (Scheduler) Entering work loop.
2021-01-19 13:32:01.006 Status: (Scheduler) Initialized version 1.0.0, author 'artbern'
2021-01-19 13:32:01.015 Error: (Scheduler) 'onStart' failed 'AttributeError':''NoneType' object has no attribute 'api''.
2021-01-19 13:32:01.015 Error: (Scheduler) ----> Line 320 in '/home/pi/domoticz/plugins/Scheduler/plugin.py', function onStart
2021-01-19 13:32:01.015 Error: (Scheduler) ----> Line 117 in '/home/pi/domoticz/plugins/Scheduler/plugin.py', function onStart
2021-01-19 13:32:01.015 Error: (Scheduler) ----> Line 148 in '/usr/lib/python3.7/DomoticzAPI/device.py', function __init__
2021-01-19 13:32:11.044 (Scheduler) onHeartbeat called
ArtBern
Posts: 11
Joined: Monday 18 January 2021 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by ArtBern »

Thanks for your interest!

Code: Select all

2021-01-19 13:32:01.015 (Scheduler) Domoticz-API server is: Server("localhost", "81"): False
Fixed this bug at recent commit. Please pull latest version and restart Domoticz (or update hardware) to restart plugin code.
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by besix »

After replacing plug-in files - new version
Domoticz crashes
I managed to catch the logs
2021-01-19 15:23:42.872 Error: Python Plugin System: (Scheduler) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Scheduler/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'.
2021-01-19 15:23:42.872 Error: Python Plugin System: (Scheduler) Module Import failed, exception: 'NameError'
2021-01-19 15:23:42.872 Error: Python Plugin System: (Scheduler) Error Line details not available.

After removing the plug-in in Hardware, domoticz continued
ArtBern
Posts: 11
Joined: Monday 18 January 2021 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by ArtBern »

Are there more logs related to Scheduler available? Prior to line with Error ?
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by besix »

I added a plugin with the debug option.
We managed to see it

2021-01-19 16:16:27.417 InfluxLink: value Percentage,idx=1,name=CPU_Usage value=27.93
2021-01-19 16:16:29.058 Error: Scheduler hardware (6) thread seems to have ended unexpectedly
2021-01-19 16:16:37.016 Status: Python Plugin System: (Scheduler) Stop directive received.
2021-01-19 16:16:37.016 Status: Python Plugin System: (Scheduler) Stopping threads.
2021-01-19 16:16:37.016 Status: Python Plugin System: (Scheduler) Stopped.
2021-01-19 16:16:37.016 Status: Python Plugin System: (Scheduler) Started.
2021-01-19 16:16:38.676 Status: Python Plugin System: (Scheduler) Stop directive received.
2021-01-19 16:16:39.177 Status: Python Plugin System: (Scheduler) Stopping threads.
2021-01-19 16:16:39.177 Status: Python Plugin System: (Scheduler) Stopped.
2021-01-19 16:16:39.177 Status: Python Plugin System: (Scheduler) Started.
2021-01-19 16:16:39.110 Error: Python Plugin System: (Scheduler) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/Scheduler/:/usr/lib/python37.zip:/usr/lib/python3.7:/usr/lib/python3.7/lib-dynload:/usr/local/lib/python3.7/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.7/dist-packages'.
2021-01-19 16:16:39.111 Error: Python Plugin System: (Scheduler) Module Import failed, exception: 'NameError'
2021-01-19 16:16:39.111 Error: Python Plugin System: (Scheduler) Error Line details not available.
ArtBern
Posts: 11
Joined: Monday 18 January 2021 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by ArtBern »

Fixed that.

Please pull lates & restart.
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by besix »

Hey
Now there is a lot of progress.
SetPiont has been added but is not configurable
There are errors in two lines

Code: Select all

2021-01-19 18:46:27.538 Error: Python Plugin System: (Scheduler) ----> Line 332 in '/home/pi/domoticz/plugins/Scheduler/plugin.py', function onMessage
2021-01-19 18:46:27.538 Error: Python Plugin System: (Scheduler) ----> Line 181 in '/home/pi/domoticz/plugins/Scheduler/plugin.py', function onMessage
All log from start
2021-01-19 18:44:56.390 Status: Python Plugin System: (Scheduler) Started.
2021-01-19 18:44:59.362 (Scheduler) onStart called
2021-01-19 18:44:59.357 Status: Python Plugin System: (Scheduler) Entering work loop.
2021-01-19 18:44:59.359 Status: Python Plugin System: (Scheduler) Initialized version 1.0.0, author 'artbern'
2021-01-19 18:45:01.245 (Scheduler) Read file: /home/pi/domoticz/plugins/Scheduler/web/html/thermostat_schedule.html
2021-01-19 18:45:01.251 (Scheduler) Read file: /home/pi/domoticz/plugins/Scheduler/web/javascript/thermostat_schedule.js
2021-01-19 18:45:01.256 (Scheduler) Read file: /home/pi/domoticz/plugins/Scheduler/web/images/downArrow_white.png
2021-01-19 18:45:01.260 (Scheduler) Read file: /home/pi/domoticz/plugins/Scheduler/web/images/downArrow_red.png
2021-01-19 18:45:01.269 (Scheduler) File created: /home/pi/domoticz/www/templates/Scheduler-Scheduler.html
2021-01-19 18:45:01.270 (Scheduler) Domoticz-API server is: Server("192.168.0.115", "8082"): True
2021-01-19 18:45:01.350 (Scheduler) Leaving on start
2021-01-19 18:45:10.883 (Scheduler) onHeartbeat called
2021-01-19 18:45:20.908 (Scheduler) onHeartbeat called
2021-01-19 18:45:30.884 (Scheduler) onHeartbeat called
2021-01-19 18:45:40.909 (Scheduler) onHeartbeat called
2021-01-19 18:45:50.884 (Scheduler) onHeartbeat called
2021-01-19 18:46:00.914 (Scheduler) onHeartbeat called
2021-01-19 18:46:10.889 (Scheduler) onHeartbeat called
2021-01-19 18:46:20.930 (Scheduler) onHeartbeat called
2021-01-19 18:46:27.447 (Scheduler) Connected successfully to: 192.168.0.6:59988
2021-01-19 18:46:27.447 (Scheduler) Name: '192.168.0.6:59988', Transport: 'TCP/IP', Protocol: 'HTTP', Address: '192.168.0.6', Port: '59988', Baud: 0, Bytes: 503, Connected: True, Last Seen: 2021-01-19 18:46:27, Parent: 'Server Connection'
2021-01-19 18:46:27.448 (Scheduler) Connected successfully to: 192.168.0.6:59989
2021-01-19 18:46:27.448 (Scheduler) Name: '192.168.0.6:59989', Transport: 'TCP/IP', Protocol: 'HTTP', Address: '192.168.0.6', Port: '59989', Baud: 0, Bytes: 442, Connected: True, Last Seen: 2021-01-19 18:46:27, Parent: 'Server Connection'
2021-01-19 18:46:27.448 (Scheduler) Connected successfully to: 192.168.0.6:59990
2021-01-19 18:46:27.448 (Scheduler) Name: '192.168.0.6:59990', Transport: 'TCP/IP', Protocol: 'HTTP', Address: '192.168.0.6', Port: '59990', Baud: 0, Bytes: 450, Connected: True, Last Seen: 2021-01-19 18:46:27, Parent: 'Server Connection'
2021-01-19 18:46:27.448 (Scheduler) onMessage called for connection: 192.168.0.6:59988:192.168.0.6:59988
2021-01-19 18:46:27.485 (Scheduler) Read file: /home/pi/domoticz/plugins/Scheduler/web/images/logo.png
2021-01-19 18:46:27.485 (Scheduler) onMessage called for connection: 192.168.0.6:59989:192.168.0.6:59989
2021-01-19 18:46:27.538 (Scheduler) onMessage called for connection: 192.168.0.6:59990:192.168.0.6:59990
2021-01-19 18:46:27.538 Error: Python Plugin System: (Scheduler) 'onMessage' failed 'TypeError':''NoneType' object is not iterable'.
2021-01-19 18:46:27.538 Error: Python Plugin System: (Scheduler) ----> Line 332 in '/home/pi/domoticz/plugins/Scheduler/plugin.py', function onMessage
2021-01-19 18:46:27.538 Error: Python Plugin System: (Scheduler) ----> Line 181 in '/home/pi/domoticz/plugins/Scheduler/plugin.py', function onMessage

Maybe up to three times a piece
I'm counting on it
ArtBern
Posts: 11
Joined: Monday 18 January 2021 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by ArtBern »

Error row number indicate problem with list of timer plans. Perhaps you have just one defined in your environment.
Could you please create second timer plan via Domoticz -> Setup -> More Options -> Plans -> Timerplan ? Then restart & reload custom page.

Later I should reproduce it on my environment and fix.
ArtBern
Posts: 11
Joined: Monday 18 January 2021 20:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by ArtBern »

As per your profile, you are using Domoticz beta. I have 2020.2 release. Timerplans are part of Domoticz settings, I should review changes in "beta" compared to release. Possibly Domoticz-API failed to read settings.

Anyway, do you have new page under Custom menu? Double click on schedule to create new value. Then click "Save", this should work regardless to Timerplans dropdown.
besix
Posts: 99
Joined: Friday 25 January 2019 11:33
Target OS: Linux
Domoticz version: beta
Location: Poland
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by besix »

I added 3 time plans
Errors are gone
The settings work but the TimerPlan tab is missing. I don't know how to insert a photo.
You have Weekends, I have a black window
link to the photo https://drive.google.com/file/d/1R6hEWv ... sp=sharing
https://drive.google.com/file/d/19tEZZ7 ... sp=sharing
This is a very good plug. Thank you
If you manage to do to the end

PS
This is how I use the Beta version, I wrote about it earlier
User avatar
JohnnySK
Posts: 25
Joined: Thursday 28 May 2015 22:14
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Slovakia
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by JohnnySK »

Will you make update for actual beta ?
API not working..
Gef77100
Posts: 2
Joined: Friday 11 February 2022 20:29
Target OS: Windows
Domoticz version:
Contact:

Re: Python Plugin: Thermostat Weekly Scheduler

Post by Gef77100 »

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest