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?
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?
Can someone please tell me where to find the SLID, I’ve tried what @cariboomentioned 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
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
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);
}
});