Hi all - not sure what category this belongs in, any advice welcome.
I use an electricity company in New Zealand that charges customers based on the current spot pricing. So I have developed a python script which scrapes the current electricity price from the website and I would now like to use this in Home Assistant so that I can automatically control devices based on the current power price.
Just looking for some guidance on how to get this info into Home Assistant - should I develop a sensor or use the the Python Scripts component instead? Thanks.
Thanks - that looks perfect. Except I canāt get the sensor to run the script. I can run the python script from the command line as the homeassistant user without issues, but it fails every time in the HA log: 2017-09-05 12:23:09 ERROR (Thread-3) [homeassistant.components.sensor.command_line] Command failed: python /home/homeassistant/.homeassistant/ha-flickprice.py
If run manually, the Python script just āprintsā the output to the terminal. How can I troubleshoot this to see why itās failing?
Hereās the sensor in my sensors.yaml file:
#Command Line sensor to get Flick price
- platform: command_line
name: Flick Spot Price
command: "python /home/homeassistant/.homeassistant/ha-flickprice.py"
unit_of_measurement: "cents"
scan_interval: 60
Replying to myself hereā¦ āVasileyā from the Discord site recommended I install hassctl and use the logging feature there to troubleshoot the script. This was perfect!
Hi @jakebriggs, I donāt mind sharing it but Iām in the process of reworking it now so that it works with Python3. Should be ready shortly but just to confirm this will only work with Flick Electricity - are you a customer of theirs?
Just wanted to say thanks for this. I have just got it working with my Hassio install and with the way the spot prices are at the moment it gonna be really handy making sure certain things arnāt on when the prices goes up stupid high.
Where would I clone the python scripts to? Somewhere in the config directory? How then do I call it so that it generates the credentials file, as Iām guessing setting it up as a sensor wonāt exactly yield a credentials file? Also, what about pipenv and those dependencies? They will also need to be installed somehow.
Let me know, because Iām quite exicted about this