BCHydro component - where did it go?

Alright, I’ve got it working!

  - platform: bchydro
    scan_interval: 36
    username: !secret bchydro_username
    password: !secret bchydro_password
    account_number: !secret bchydro_account_number
    slid: !secret bchydro_slid

I need to look up how I found the slid again, but im excited it is working!!

Can you share what you put in your configuration.yaml and where you put the custom component?

Thank you

Where do you find the slid?

You can find it on your bill

I used HACS To install the custom component from my github: https://github.com/hdsheena/custom_components
And my config yaml entry is

  - platform: bchydro
    scan_interval: 36
    username: !secret bchydro_username
    password: !secret bchydro_password
    account_number: !secret bchydro_account_number
    slid: !secret bchydro_slid

I’d like to improve the way this gets data, I think it would be pretty easy to have it grab the hourly data rather than just the “Current usage” if anyone else is interested in this?

I’d definitely be interested in a “current usage” if someone can figure it out.

I think I’ve got the slid, does it look like this?

800000000XXXXXXX000023609000011578

I removed the extra spaces, and in the example I X’d out my account number

What information can you get from BC Hydro through this component? I know you can get daily consumption one day behind in your online account, and their smart speaker support function for Alexa and Google Home can tell you consumption to date this month and an approximate breakdown of power usage type. Is there any way to get real-time power usage, or is that data not communicated so often?

Hello all :wave:,

Can someone please tell me where to find the SLID, I’ve tried what @cariboo mentioned but I’m getting this error

bchydro: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 291, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 419, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/bchydro/sensor.py", line 62, in update
    self._state = self._api.latest_usage()
  File "/config/custom_components/bchydro/sensor.py", line 127, in latest_usage
    for point in root.findall('Series')[0].findall('Point'):
IndexError: list index out of range

all my other credentials are correct. Any help would be appreciated :heart:

Thanks

This is just scraping from the web interface, and that’s not real-time, so this solution won’t offer real time tracking.
SLID:
Go to your bcHydro account page, and use “Inspect Element” in your browser.
Navigate to the detailed consupmtion page and go to “Network” in the inspector. Search “xml” to filter the list, and find consumption.xml
Look at the “Form Data” section in the headers tab for your SLID

2 Likes

IT WORKED!!! Using the SLID and “Account” from the xml file and my username and password.

Thank you so much :heart: :grinning:

1 Like

Hi, the BC hydro sensor was working perfectly! And then it broke…

Is this happening to anyone else?

Mine is just disappeared… maybe I need to make a change based on the newest updates?

1 Like

Can someone confirm what version it DOES work on for me? That will help!

Hmm… What versions are you referring to Courtenay?

I’m missing this sensor :cry:

Home Assistant versions.

Here’s the error: bchydro:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/xml/etree/ElementTree.py", line 1630, in feed
    self.parser.Parse(data, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 80, column 15

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 292, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 448, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/bchydro/sensor.py", line 62, in update
    self._state = self._api.latest_usage()
  File "/config/custom_components/bchydro/sensor.py", line 125, in latest_usage
    root = ET.fromstring(r.text)
  File "/usr/local/lib/python3.7/xml/etree/ElementTree.py", line 1315, in XML
    parser.feed(text)
  File "/usr/local/lib/python3.7/xml/etree/ElementTree.py", line 1632, in feed
    self._raiseerror(v)
  File "/usr/local/lib/python3.7/xml/etree/ElementTree.py", line 1531, in _raiseerror
    raise err
  File "<string>", line None
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 80, column 15

I think bchydro added this bit… and maybe thats the problem:

$(document).bind("ajaxSend", function(elm, xhr, s){
         var bchydroparamVal = $('#bchydroparam').html();
         if (s.type == "POST") {  //This can be extended for GET requests also
           //for new apps
           xhr.setRequestHeader('bchydroparam', bchydroparamVal);
           //for legacy code  
           xhr.setRequestHeader('X-CSRF-Token', bchydroparamVal); 
         }
     });

Worked on this for a few hours yesterday, and at least got the login piece working in a standalone script, but it breaks when I put it back into HA. :frowning:

Hi Courtenay,

Could I please have the script you made? I think I could run it outside of hassio and then put the data back into hassio.

Thanks :slight_smile:

1 Like