maorcc / citymind_water_meter

Home Assistant Integration with cp.city-mind.com, an Israeli water meters reading service
Apache License 2.0
41 stars 2 forks source link

multiple meters - wrong data for some parameters #34

Closed arnonsha closed 1 year ago

arnonsha commented 2 years ago

Per your request in issue #4 , I am posting the debug data json file (sensitive data removed). I am diffing against the old web site data (cp.city-mind.com) I can see the following: 1) All 3 meters that I have are identified correctly: meter id, names, readouts. 2) The "consumption-daily" has 2 values for each meter which represents yesterday's and today's consumption. Unfortunately these 2 values are identical to all 3 meters which is wrong. Looking at the website data, these numbers don't belong to any of the 3 meters :-) 3) "Consumption forcast" fields seems OK 4) "consumption-monthly" shows same val for all 3 meters. Also what is the diff between "consumption forcast" and "consumption-monthley" ? 5) customer-service fields looks OK 6) I think all the numbers are a bit off (few %). Again, I am comparing to the data posted in the old API. Maybe it it a bit different. Let's deal with it later.

{
  "version": 1,
  "minor_version": 1,
  "key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "data": {
    "consumption-daily": {
      "192": [
        {
          "commonCons": 0.0,
          "cons": 3.2269999999999186,
          "consDate": "2022-10-16T00:00:00",
          "estimationType": 0,
          "meterCount": 0,
          "meterStatusDesc": ""
        },
        {
          "commonCons": 0.0,
          "cons": 0.6879999999999313,
          "consDate": "2022-10-17T00:00:00",
          "estimationType": 0,
          "meterCount": 0,
          "meterStatusDesc": ""
        }
      ],
      "193": [
        {
          "commonCons": 0.0,
          "cons": 3.2269999999999186,
          "consDate": "2022-10-16T00:00:00",
          "estimationType": 0,
          "meterCount": 0,
          "meterStatusDesc": ""
        },
        {
          "commonCons": 0.0,
          "cons": 0.6879999999999313,
          "consDate": "2022-10-17T00:00:00",
          "estimationType": 0,
          "meterCount": 0,
          "meterStatusDesc": ""
        }
      ],
      "194": [
        {
          "commonCons": 0.0,
          "cons": 3.2269999999999186,
          "consDate": "2022-10-16T00:00:00",
          "estimationType": 0,
          "meterCount": 0,
          "meterStatusDesc": ""
        },
        {
          "commonCons": 0.0,
          "cons": 0.6879999999999313,
          "consDate": "2022-10-17T00:00:00",
          "estimationType": 0,
          "meterCount": 0,
          "meterStatusDesc": ""
        }
      ]
    },
    "consumption-forcast": {
      "192": {
        "estimatedConsumption": 38.307764705882136
      },
      "193": {
        "estimatedConsumption": 3.184941176470602
      },
      "194": {
        "estimatedConsumption": 41.38352941176452
      }
    },
    "consumption-monthly": {
      "192": [
        {
          "cons": 44.02799999999979,
          "consDate": "2022-10-01T00:00:00"
        }
      ],
      "193": [
        {
          "cons": 44.02799999999979,
          "consDate": "2022-10-01T00:00:00"
        }
      ],
      "194": [
        {
          "cons": 44.02799999999979,
          "consDate": "2022-10-01T00:00:00"
        }
      ]
    },
    "customer-service": {
      "Email": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "description": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "municipalID": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "phoneNumber": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    },
    "last-read": [
      {
        "meterCount": 192,
        "meterId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "read": 1365.963
      },
      {
        "meterCount": 193,
        "meterId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "read": 386.666
      },
      {
        "meterCount": 194,
        "meterId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "read": 1824.072
      }
    ],
    "last-update": "2022-10-17 18:09:11.060463",
    "me": {
      "accountNumber": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "firstName": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "lastName": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "municipalId": xxxxxxxxxxxxxxxxxxxxxxxxxxxx,
      "phoneNumber": {
        "AdditionalPhoneNumber": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "countryCode": null,
        "phoneNumber": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      }
    },
    "meters": [
      {
        "fullAddress": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "meterCount": 192,
        "meterSn": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      },
      {
        "fullAddress": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "meterCount": 193,
        "meterSn": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      },
      {
        "fullAddress": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "meterCount": 194,
        "meterSn": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
      }
    ],
    "my-alerts": [],
    "my-messages": [],
    "settings": [
      {
        "alertTypeId": 23,
        "mediaTypeId": 1
      }
    ],
    "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "vacations": []
  }
}
elad-bar commented 2 years ago

since I have just 1 meter on my account, I can't reproduce it and find how it should work, there are 2 options to make it work, over online call or you assistint with developer tools at your browser extracting the requests and responses of the portal, please let me know how do you prefer to promote it

thanks

arnonsha commented 1 year ago

Sorry for the late reply. I was quite busy at work. I'd like to do the debug on my own if that's ok with you, but I'll probably need help so let's do an online call where you can show me what to look for in my browser. I don't think there's a way to send PMs in Github, so I'll send you my contact info through @maorcc

elad-bar commented 1 year ago

Hi,

Can you please open the portal while developer yools is opened on network tab? Once you have done it, make sure the preserve checkbox is checked, Then perform a login, A list of web api / pages will appear in that tab of network, I need to understand what is the data being send and return for the first page (request url / response json), Once you have it I can use that information to understand if we need add additional requests to the integration.

Thanks, Elad

elad-bar commented 1 year ago

Created a discord channel for better communication https://discord.gg/Nwv9QmAs

arnonsha commented 1 year ago

Ah..I think I now understand what's going on:

When you log in, you get the list of all meters (unique id (integer) and name (string)). You also get the last readout. This is done through this URL: https://api-ctm.city-mind.com/consumption/monthly/2022-10/2022-10-31

To get more details on a specific meter you need to choose the meter from a drop down menu

image

In the menu all meters appears. I have 3 so there are 4 items to choose from:

Screenshot_1

Once I choose a meter, I see the above URL with the addition of the chosen meter https://api-ctm.city-mind.com/consumption/monthly//2022-10/2022-10-31 where meter number is any of the integers returned earlier in the "meters" field when I logged in. mine are numbered 192, 193 and 194.

So I guess dedicated GETs should be performed for every meter

Hope that helps

elad-bar commented 1 year ago

Ok, that's make perfect sense and exactly what i was looking for, to understand how the parameter is being passed for each of the calls, Can I send you a postman project to verify all calls are working correctly?

Thanks

elad-bar commented 1 year ago

@arnonsha thanks for the details, it assisted understanding the new API much better, please check if v2.0.3 works for you.

thanks

arnonsha commented 1 year ago

Thank you @elad-bar I updated and will check it in the coming days.

arnonsha commented 1 year ago

Hi I can confirm that all numbers for the individual meters are correct. That is great and makes this add on usable for anyone with multiple meters. Thank you very much !

2 improvements that may help: 1) As we have discussed above, the rym-pro.com landing page returns the readouts/consumption forecast for all meters combined. Currently I don't use to this info, however someone else might. I suggest to have this info as dedicated device. So or n meters there would be n+2 devices: n "water meter" devices, 1 "account" device, and 1 "all meters" device. What do you think ?

2) Not sure if this is a homeassistant issue or the addon issue: I am trying to rename the meter device and give them a meaningful name, rather than stick with the meter serial number:

image

The new device name is kept some time for some time (not sure if it's hours or days),after which it is overrun by the original name with the serial number. Is that the add on or homeassistant responsible for this behavior ?

elad-bar commented 1 year ago

Great news, thanks for the update!

Regarding 1 - the component should provide the capability not aggregation, Aggregation can be performed in more suitable for that purpose like Grafana.

For now there is a device for the account and for each meter, If you would like to have aggregation, you can use aggregation template sensors or Grafana ad I mentioned above (which I'm using).

2 sounds like an issue, will check it, please report on it as different issue while this one should be closed.

Thanks

arnonsha commented 1 year ago

OK, thanks for explaining that. I will close this one and open a new one for 2 above