pihome-shc / pihome

PiHome - Smart Heating, Ventilation and Air Conditioning (HVAC)
http://www.pihome.eu
Other
52 stars 25 forks source link

Zones used only for temperature display #393

Open twa127 opened 3 years ago

twa127 commented 3 years ago

Leading on from @scottagecheeseandcrackers comment about having zones simply measuring temperature, what do you all think about being able to display temperature sensors without having to setup a 'dummy' zone. This could be achieved by -

The home screen would look like this sensor1

pihome-shc commented 3 years ago

as of now we have zone enable checkbox and zone gets created same way i.e even if zone is only for monitoring it still have controller attached to it, instead of creating another table may be creating zone process need re-thinking

twa127 commented 3 years ago

Hi,

Yes that is exactly how I use the system at the moment with the zone enable checkbox. My thinking is that these monitoring points are not really zones at all and perhaps should not be cluttering up the zone table and as you say they need to have a controller and other data allocated needlessly. This was why I was suggesting separating the temperature measuring points out to a separate table

twa127 commented 3 years ago

I've progressed this a bit further -

  1. Added an Add Sensor option to the One Touch Menu
  2. Modified Zone Add/Edit to use a single field to select sensor by name
  3. Changed the home screen to display temperature sensors not attached to a zone on the right of the boiler tile and before any add-ons
  4. Changed boiler.php work with the new format zone_sensors table
  5. Created migrate_sensors.php to create the new temperature_sensors table, modify the zone_sensors table and move the data
  6. Note I have copied the zone names to the temperature sensors names but you might want to change the names to match location rather than zone.
  7. Still outstanding is a GUI to delete/edit temperature sensors and the graphs

This is what it looks like on my test system (no gateway setup, so temperature sensors shown as timed-out)

sensor2 temperature_sensors.zip

twa127 commented 3 years ago

Moved on again, now added a GUI for the Temperature Sensors, it can be found in the Node and Zone Configuration settings menu. I've moved the original Sensors option to the Status menu as I thought it filled a bit better here. The GUI works a bit like the Zones option.

sensor3

Although it needed a new table, the overall data storage is reduced by not saving unnecessary zone info, also easy to swap active zones controlling sensor, selection is by temperature sensor name, rather than node_id, so easier to see choose the right sensor :-)

I'll move on to the graphs next.

All comments most welcome temperature_sensors.zip

pihome-shc commented 3 years ago

@twa127 i will give it try later and come back to you. first impression looks nice.

twa127 commented 3 years ago

A little tweak to allow being able to choose whether a temperature sensor is displayed on the home screen

sensor4

temperature_sensors.zip

pihome-shc commented 3 years ago

@twa127 do i have to run migrate_sensor.php as well?

twa127 commented 3 years ago

yes because I've added a new field to the temperature_sensors table, you need to go back to the database you had before running migrate_sensors.php and the re-run migrate_sensors.php

pihome-shc commented 3 years ago

ok i did test and migration worked ok, but i deleted all deactivated zone and try to add again and i get following error.

image

three suggestions:

  1. also add disabled delete button for all in use sensors as well makes it look nice on gui.
  2. add sensors last report time as it is very helpful.
  3. show unassigned sensors so users know which sensors are available. image
pihome-shc commented 3 years ago

have error in boiler.php

2020-09-18 18:18:04 - Zone: Sensor Reading     23.50
2020-09-18 18:18:04 - Zone: Weather Factor     0.5
2020-09-18 18:18:04 - Zone: DeadBand           0.5
2020-09-18 18:18:04 - Zone: Cut In Temperature        0
2020-09-18 18:18:04 - Zone: Cut Out Temperature       0
2020-09-18 18:18:04 - Zone: Mode       0
2020-09-18 18:18:04 - Zone ID: 35
2020-09-18 18:18:04 - Zone: Hot Water Controller: 0 Controller Child: 33 Zone Status: 0
2020-09-18 18:18:04 - Zone: Hot Water Stop Cause: No Schedule - Target C:0 Zone C:23.50
----------------------------------------------------------------------------------------
PHP Warning:  mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in /var/www/cron/boiler.php on line 273
2020-09-18 18:18:04 - Zone ID: 58
2020-09-18 18:18:04 - Zone: Office Controller: 0 Controller Child: 3 Zone Status: 0
2020-09-18 18:18:04 - Zone: Office Stop Cause: No Schedule
----------------------------------------------------------------------------------------
PHP Warning:  mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in /var/www/cron/boiler.php on line 273
2020-09-18 18:18:04 - Zone ID: 59
2020-09-18 18:18:04 - Zone: Hall Controller: 0 Controller Child: 3 Zone Status: 0
2020-09-18 18:18:04 - Zone: Hall Stop Cause: No Schedule
twa127 commented 3 years ago

Okay fixed the error in sensors.php.

Sorry not too sure about points 1-3, I see that sensors menu as for displaying status, so would probably remove the delete button altogether and use the sensors configuration GUI to delete, this also shows the unallocated sensors.

I'll look at boiler.php, can you post the database please sensor.zip

twa127 commented 3 years ago

ah light bulb moment 1-3 rather than an empty cell show a disabled delete icon, same for the Show tickbox :-) Not too sure if I can make enough table space to show the last seen time

twa127 commented 3 years ago

sensor5

pihome-shc commented 3 years ago

Few more suggestions Moving edit and delete in one column can same space. Change Node child id to child id. For last seen: how about second line under sensors name? May be bit small text.

twa127 commented 3 years ago

How about sensor8 model.zip

pihome-shc commented 3 years ago

@twa127 looks good, question where sensors name comes from? i.e in your image you have New Zone and Zone name not allocated.

twa127 commented 3 years ago

Hi

The Sensor Name comes from the temperature_sensors table and can be set to whatever you want to identify the location of the sensor. If the sensor is being used by a zone, then the Zone Name comes from the zone table, if not being used by a zone, then the Zone Name will be 'Not Allocated'.

twa127 commented 3 years ago

Attached latest version with code for the graphs. If a sensor is unallocated it will be displayed by sensor name, if allocated to a zone it will be displayed by zone name. sensor11

@pihome-shc do you still have a problem with boiler.php ?

temperature_sensors.zip

pihome-shc commented 3 years ago

on gui all looks ok here is output for boiler.php

2020-09-20 11:27:59 - Boiler Script Started
2020-09-20 11:27:59 - Day of the Week: 0
----------------------------------------------------------------------------------------
2020-09-20 11:27:59 - Hysteresis time: 2020-09-20 11:30:33
2020-09-20 11:27:59 - Zone: Sensor Reading     18.60
2020-09-20 11:27:59 - Zone: Weather Factor     0.5
2020-09-20 11:27:59 - Zone: DeadBand           0.5
2020-09-20 11:27:59 - Zone: Cut In Temperature        0
2020-09-20 11:27:59 - Zone: Cut Out Temperature       0
2020-09-20 11:27:59 - Zone: Mode       100
2020-09-20 11:27:59 - Zone ID: 33
2020-09-20 11:27:59 - Zone: Ground Floor Controller: 0 Controller Child: 29 Zone Status: 0
2020-09-20 11:27:59 - Zone: Ground Floor Stop Cause: Hysteresis active  - Target C:0 Zone C:18.60
----------------------------------------------------------------------------------------
2020-09-20 11:27:59 - Hysteresis time: 2020-09-20 11:30:33
2020-09-20 11:27:59 - Zone: Sensor Reading     20.00
2020-09-20 11:27:59 - Zone: Weather Factor     0.5
2020-09-20 11:27:59 - Zone: DeadBand           0.5
2020-09-20 11:27:59 - Zone: Cut In Temperature        0
2020-09-20 11:27:59 - Zone: Cut Out Temperature       0
2020-09-20 11:27:59 - Zone: Mode       100
2020-09-20 11:27:59 - Zone ID: 34
2020-09-20 11:27:59 - Zone: First Floor Controller: 0 Controller Child: 31 Zone Status: 0
2020-09-20 11:27:59 - Zone: First Floor Stop Cause: Hysteresis active  - Target C:0 Zone C:20.00
----------------------------------------------------------------------------------------
2020-09-20 11:27:59 - Hysteresis time: 2020-09-20 11:30:33
2020-09-20 11:27:59 - Zone: Sensor Reading     31.50
2020-09-20 11:27:59 - Zone: Weather Factor     0.5
2020-09-20 11:27:59 - Zone: DeadBand           0.5
2020-09-20 11:27:59 - Zone: Cut In Temperature        0
2020-09-20 11:27:59 - Zone: Cut Out Temperature       0
2020-09-20 11:27:59 - Zone: Mode       100
2020-09-20 11:27:59 - Zone ID: 35
2020-09-20 11:27:59 - Zone: Hot Water Controller: 0 Controller Child: 33 Zone Status: 0
2020-09-20 11:27:59 - Zone: Hot Water Stop Cause: Hysteresis active  - Target C:0 Zone C:31.50
----------------------------------------------------------------------------------------
PHP Warning:  mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in /var/www/cron/boiler.php on line 274
2020-09-20 11:27:59 - Zone ID: 58
2020-09-20 11:27:59 - Zone: Office Controller: 0 Controller Child: 3 Zone Status: 0
2020-09-20 11:27:59 - Zone: Office Stop Cause: No Schedule
----------------------------------------------------------------------------------------
PHP Warning:  mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in /var/www/cron/boiler.php on line 274
2020-09-20 11:27:59 - Zone ID: 59
2020-09-20 11:27:59 - Zone: Hall Controller: 0 Controller Child: 3 Zone Status: 0
2020-09-20 11:27:59 - Zone: Hall Stop Cause: No Schedule
----------------------------------------------------------------------------------------
2020-09-20 11:27:59 - Zone: GIOP Relay Status: 1 (0=On, 1=Off)
2020-09-20 11:27:59 - Zone: GIOP Relay Status: 1 (0=On, 1=Off)
2020-09-20 11:28:00 - Zone: GIOP Relay Status: 1 (0=On, 1=Off)
2020-09-20 11:28:00 - Zone: GIOP Relay Status: 1 (0=On, 1=Off)
2020-09-20 11:28:00 - Zone: GIOP Relay Status: 1 (0=On, 1=Off)
2020-09-20 11:28:01 - Boiler Switched Off At: 2020-09-20 11:27:33
2020-09-20 11:28:01 - Boiler GIOP: 35 Status: 1 (0=On, 1=Off)
2020-09-20 11:28:01 - Boiler Fired Status: 0
2020-09-20 11:28:01 - Boiler Hysteresis Status: 1
----------------------------------------------------------------------------------------
2020-09-20 11:28:01 - Boiler Script Ended
****************************************************************************************
twa127 commented 3 years ago

Can you let me have a dump of your database please, so I can reproduce the error

pihome-shc commented 3 years ago

this is my current db without any changes

pihome_mysql_2020-09-20_11-26-27.zip

twa127 commented 3 years ago

This should fix it :-) boiler.zip

pihome-shc commented 3 years ago

boiler.php error is fixed now, i have two wired sensors connected to my rpi and they are working ok, and records are in nodes table but i can not see them under setting->sensors

twa127 commented 3 years ago

job for tomorrow :-))

pihome-shc commented 3 years ago

here is the database after some cleanup work. also graph wasnt working after your changes.

pihome_mysql_2020-09-20_23-04-06.zip

twa127 commented 3 years ago

Hi,

I can see your wired sensors okay sensor14

pihome-shc commented 3 years ago

This is odd, did you update my last Database? Reason: i have removed disabled zone and left the sensors and I wasn’t able to see them

twa127 commented 3 years ago

The problem with your latest database is that the migration process uses the zone table as the basis for building the initial migrated temperature_sensors table, using the status field to determine if the senor is allocated. I did it this way as I could not use the nodes table to identify sensors by child id, as a single node table entry may equate to multiple sensors. This is also why the temperature_sensors table cannot be automatically update when a new node is added.

In the case of your cleaned-up database, simply use the Add Temperature Sensor GUI to add the 2 GPIO sensors.

Your database did show up an error in homelist.php, which I've fixed in the attached. homelist.zip

I see the basic setting up the system workflow as -

  1. Nodes added either automatically by discovery (MySensors or GPIOSensor) or by manual entry (GPIO, I2C or Add-On)
  2. Temperature Sensors added from GUI
  3. Zones added from GUI
twa127 commented 3 years ago

Did you update gateway.py, needed for graphs ?

Fixed a bug in migrate_sensors.php which stopped column sensor_id in table zone_sensors from being dropped

migrate_sensor.zip

twa127 commented 3 years ago

Fixed the GPIO Sensor Graphs, but graphs still a work in progress

gpio_ds18b20.zip

twa127 commented 3 years ago

Update for charts charts.zip

pihome-shc commented 3 years ago

reason i send database after cleanup was so we have way to see sensors under setting. i.e what if i connect new gpio sensors or power on new mysensors temperature sensor?

i copied all files from your zip file, but i didnt kill gateway.py process to get new version running. homelist.php only related to my setup? i haven't made any changes to homelist.php

i m updating with your recent zip files and report back to you.

twa127 commented 3 years ago

Hi,

If you add nodes which automatically create new nodes table entries, then at present you need to manually add new sensors. I guess it is possible to add temperature_sensors table entries at the same time in gateway.py and gpio_ds18b20.py

new homelist.php is a bug fix which I found using your latest database which had no add-ons

pihome-shc commented 3 years ago

add sensor -> sensor.php is missing.

twa127 commented 3 years ago

attached latest copies of everything update.zip

twa127 commented 3 years ago

ah see what you mean, I'll re-fix model :-)

twa127 commented 3 years ago

Fixed model.php model.zip

pihome-shc commented 3 years ago

i added sensors now, and i see both entries in temperature_sensors without zone, this will create problem with piconnect

image

twa127 commented 3 years ago

what's the issue with piconnect, the NULL zone_id ?

pihome-shc commented 3 years ago

yes, PiConnect wouldn't work with Null values,

twa127 commented 3 years ago

okay how about using zone_id = 0 to indicate an un_allocated zone ?

pihome-shc commented 3 years ago

but there is nothing on other end of zone_id=0

twa127 commented 3 years ago

yes if the temperature sensor is un-allocated then it can't have a valid zone_id, is that going to screw piconnect ?

twa127 commented 3 years ago

Attached changed files for a zone_id = 0 version, does this resolve the piconnect problem ? Zone0.zip

twa127 commented 3 years ago

Hi

Question about Zone Delete, from what I can see, the process is -

  1. db.php sets purge=1 in all the zone related tables
  2. the cronjob piconnect.php runs every minute and deletes the records from the same tables where purge=1

What's the reason for simply not deleting the relevant records at the db.php stage ?

pihome-shc commented 3 years ago

Reason to keep deleting of records in PiConnect is to offer remote management of PiHome once PiConnect becomes available for general public. Hence sync set to 0 for sync data with PiConnect.

twa127 commented 3 years ago

I understand, but can cause a potential problem, for example zone_log records purge set to 1, then boiler.php adds another record before piconnect,php runs and the zone deletion fails do FK constraint

pihome-shc commented 3 years ago

That is why it is important to have correct delete sequence in piconnect.php which is correct at the moment.

twa127 commented 3 years ago

That's not the issue, if -

db.php sets Purge = 1, then piconnect.php runs before boiler.php - OK db.php sets Purge = 1, then boiler.php runs before piconnect.php and boiler.php does not INSERT new zone log record - OK db.php sets Purge = 1, then boiler.php runs before piconnect.php and boiler.php does INSERT new zone log record - FK constraint error

If piconnect.php always runs before boiler.php then no problem, but I don't know how crontab orders multiple jobs that run at the same time interval

twa127 commented 3 years ago

It would appear crontab

So we have boiler.php starting before piconnect.php, without piconnect.php waiting for boiler.php to finish