https://github.com/emcniece/hass-bchydro
Home Assistant BCHydro Sensor
https://github.com/emcniece/hass-bchydro
bchydro hass power-monitoring sensors
Last synced: about 1 month ago
JSON representation
Home Assistant BCHydro Sensor
- Host: GitHub
- URL: https://github.com/emcniece/hass-bchydro
- Owner: emcniece
- Created: 2020-08-07T07:20:06.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-03-08T18:40:59.000Z (over 3 years ago)
- Last Synced: 2024-04-13T22:41:39.084Z (over 1 year ago)
- Topics: bchydro, hass, power-monitoring, sensors
- Language: Python
- Homepage:
- Size: 46.9 KB
- Stars: 17
- Watchers: 7
- Forks: 8
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Home Assistant BCHydro Sensor
🚧 In development, but you can copy `sensor.py` down to your HASS install: just copy-paste `sensor.py` into a file name the same inside your HASS `custom_components/bchydro` directory. Edit `bchydro_username` and `bchydro_password` to match your BCHydro account.
## Installation
Place these files inside a directory in your custom_components directory:
```sh
cd config/custom_components
git clone git@github.com:emcniece/hass-bchydro.git
```Then edit your configuration.yml to include this under sensors:
```yml
sensors:
- platform: bchydro
username: !secret bchydro_username
password: !secret bchydro_password
```Then edit your secrets.yml to include your BCHydro account details:
```yml
bchydro_username: myemail@domain.com
bchydro_password: mypassword
```Then restart your HASS installation and configure your new entites!
## BCHydro Data Formats
Several calls are made to the BCHydro website for varying purposes.
### Account Data
The `URL_ACCT_INFO` URL is used to obtain the user account `slid` which is later used for fetching usage data. This endpoint has a lot of other info that might be useful for consumption at a later time - here's a sample of the JSON response:
```js
{
"accountType": "residential",
"evpSlid": "0001111111",
"evpAccount": "000011111111",
"evpAccountId": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"evpProfileId": "bchusername",
"evpRateCategory": "BCRSE1101",
"evpBillingClass": "Residential",
"evpRateGroup": "RES1",
"evpReadRoute": "BAAAAAAA",
"evpBillingStart": "2020-06-06T00:00:00-07:00",
"evpBillingEnd": "2020-08-06T00:00:00-07:00",
"evpBilledStart": "2020-04-07T00:00:00-07:00",
"evpBilledEnd": "2020-06-05T00:00:00-07:00",
"evpValidityStart": "2020-06-29T00:00:00-07:00",
"evpValidityEnd": "9999-12-31T00:00:00-08:00",
"evpEnablementDate": "2012-12-23T23:00:00-08:00",
"evpHeatingType": "N",
"evpPremiseType": "10",
"evpPostalCode": "V1V 1V1",
"evpBillingArea": "99",
"evpConsToDate": "584kWh",
"evpCostToDate": "$67",
"yesterdayPercentage": "97",
"evpStepThreshold": "1375.89",
"evpDaysInBillingPeriod": "62",
"evpStepThresholdDate": "",
"evpEstConsCurPeriod": "594",
"evpEstCostCurPeriod": "68",
"evpCurrentDateTime": "2020-08-06T23:30:46-07:00",
"evpRole": "user",
"evpCsrId": "bchusername",
"evpComLastBillingPeakDemand": "",
"evpComLastBillingPowerFactor": "",
"enableSMSAlerts": "true",
"nonWan": "False",
"timezone": "GMT",
"isEnDateinCBP": "True"
}
```### Usage Data
Points may be one of `INVALID`, `ACTUAL`, `ESTIMATED`(?). While evidence of `ESTIMATED` has been captured it seems to occur infrequently. This is something to plan for in the future and is noted in the ToDo.
After logging in, the usage `URL_GET_USAGE` URL returns data like this:
```html
```
In the sensor API, each of these `` elements is processed like so:
```py
for point in root.findall('Series')[0].findall('Point'):
print(point.items())
# [
# ('type', 'SMI'),
# ('quality', 'ACTUAL'),
# ('dateTime', '2020-07-30T00:00:00-07:00'),
# ('endTime', '2020-07-30T00:00:00-07:00'),
# ('value', '16.88'),
# ('cost', '0.00')
# ]
```## ToDo
- [ ] Unit tests + CI
- [ ] Figure out how to read secrets
- [ ] Implement HASS config flow for browser-based entry of secrets
- [ ] Hass.io, integration, Supervisor, HACS compatibility
- [ ] Add more sensors for `days_since_billing`, `consumption_to_date`, `cost_to_date`, `estimated_consumption`, `estimated_cost`
- [ ] Handle `ESTIMATED` datapoints
- Parse dates and only take `latest_usage` from days matching the current timestamp?## References
- [HASS Community discussion](https://community.home-assistant.io/t/bchydro-component-where-did-it-go/123371/33)