masaccio / ha-kingspan-watchman-sensit

Kingspan Connect Sensor integration for Home Assistant
MIT License
9 stars 0 forks source link

Integration only shows one tank #3

Closed sftgunner closed 1 year ago

sftgunner commented 1 year ago

Hi! I've been using your integration for a little bit now, and it's worked really well. However, last week I got a second sensor installed on a second oil tank, and wanted to monitor both of them in home assistant.

However, only one of them appears at a time in HA - is this intentional functionality? I'm aware my use case isn't exactly standard, but I'm happy to try and help out to get it working.

I've tried adding the sensors independently by using the BOX2000#### username that includes each tank's serial number instead of my registered email address, but unfortunately this only works for the second physical sensor I added to my Kingspan account, not the first (the login fails when trying the same trick on the first physical sensor I attached to my Kingspan account).

masaccio commented 1 year ago

Are both tanks registered to the same Sensit account? The underlying library does support multiple tanks though I've not been able to test that since I only have one myself. How comfortable are you with a command line? If you don't mind being a tester for me, I could give you some changes to the command-line utility that will at least give me an idea of how to query the data. Then I'd need to figure out how HA manages multiple devices from the same integration.

sftgunner commented 1 year ago

Yep, both on the same account. Just tried using the python library; it seems to be working fine returning data for both tanks as you'd expect. Happy to work with CLI and also to be a tester as needed!

masaccio commented 1 year ago

You would need to do this (latest version is 2.1.0).

pip install kingspan-connect-sensor
kingspan-status --username you@domain.com --password s3cret

Obviously changing the credentials to the ones for your account.

I've just published a new version that should run over the list of tanks and print out the status for each tank. Something like this:

The Chapel:
    Capacity = 1300
    Serial Number = 2000XXXXX
    Model = Unknown
    Level = 50% (661 litres)
    Last Read = 2023-02-26 02:39:37.103000

History:
    Reading date           %Full  Litres
    25-Jan-2021 13:59      100    1296 
    26-Jan-2021 00:59      0      0    
    27-Jan-2021 00:59      94     1224 
    28-Jan-2021 00:59      94     1224 
    29-Jan-2021 00:59      94     1224 
    30-Jan-2021 00:29      94     1224 
    31-Jan-2021 00:59      80     1040 
sftgunner commented 1 year ago

Can confirm that version 2.1.0 works as intended: my output is as follows:

Oil Tank (Primary):
    Capacity = 2500
    Serial Number = [REDACTED]
    Model = H2500BT
    Level = 96% (2405 litres)
    Last Read = 2023-02-26 08:54:10.263000

History:
    Reading date           %Full  Litres
    21-Feb-2023 12:33      4      110  
    22-Feb-2023 01:33      23     579  
    23-Feb-2023 00:03      22     557  
    24-Feb-2023 00:21      22     557  
    25-Feb-2023 08:20      94     2359 
    26-Feb-2023 08:54      96     2405 
Oil Tank (Annex):
    Capacity = 2500
    Serial Number = [REDACTED]
    Model = H2500BT
    Level = 100% (2500 litres)
    Last Read = 2023-02-26 14:34:39.967000

History:
    Reading date           %Full  Litres
    01-Feb-2023 13:39      71     1776 
    02-Feb-2023 10:35      72     1793 
    03-Feb-2023 11:37      71     1776 
    04-Feb-2023 11:41      70     1759 
    05-Feb-2023 13:32      70     1741 
    06-Feb-2023 10:50      70     1741 
    07-Feb-2023 11:35      68     1707 
    08-Feb-2023 11:49      68     1707 
    09-Feb-2023 11:57      68     1707 
    10-Feb-2023 11:33      68     1690 
    11-Feb-2023 09:34      67     1672 
    12-Feb-2023 11:58      66     1655 
    13-Feb-2023 11:38      66     1655 
    14-Feb-2023 13:09      66     1638 
    15-Feb-2023 10:16      66     1638 
    16-Feb-2023 01:19      66     1638 
    17-Feb-2023 01:54      65     1621 
    18-Feb-2023 04:46      65     1621 
    19-Feb-2023 10:38      65     1621 
    20-Feb-2023 09:38      65     1621 
    21-Feb-2023 01:04      64     1603 
    22-Feb-2023 12:50      63     1569 
    23-Feb-2023 13:52      62     1552 
    24-Feb-2023 11:40      62     1552 
    25-Feb-2023 11:44      86     2138 
    26-Feb-2023 14:34      100    2500 
masaccio commented 1 year ago

Great, thanks. That was the easy bit. I'll see what I can do in the HA integration.

masaccio commented 1 year ago

So I think I have something that could work. It doesn't seem to have broken my integration and the tests report 2 devices. Let me know how you get on after a HACS update

sftgunner commented 1 year ago

Blimey, that has got to be the fastest I've ever seen an issue fixed on a HA component before! That is all working perfectly post-update to 28e6a0a4cd826f11ed5fc6d7abd83216ee115f5b - very many thanks! The only bug (which is not an issue from my side at all, but thought I'd let you know!) is that the "Model" in HomeAssistant for each tank is now set as (or rather, not set), in comparison to before when it was the same as the tank name (and consequently, device name in HA). That might well be intentional, but I couldn't see any indication either way in the commit diffs.

masaccio commented 1 year ago

I made another update for the model, and also found the docs explaining how HACS presents versions and change logs on updates so that should be a lot clearer now.

sftgunner commented 1 year ago

Updated, and models now appearing! Very many thanks again :)