CurrentCost data into Home Assistant?

Has anyone got CurrentCost energy data coming into HASS? Any pointers/link/scripts available?

Background: Have CurrentCost with VeraLite working (had) but it’s got an issue, so I want to get off Vera. HA looks very interesting/good, but ultimately one of key things I do is need realtime access to power data from CurrentCost, which I then act on within automation scripts. Being is Australia there seems to be no z-wave based energy clamp devices here, i.e. with Australian z-wave frequencies, so it seems like I need to keep using my CurrentCost. I would be looking at going down the Python with appdaemon path within Home Assistant I would imagine (looks most flexible).

doesn’t look like that exists. If you know how the API works, you could write one with python. There are plenty of examples you could emulate, you would just need to change the api calls. Just pick any web based component that use a username/password for log in and reuse as much code as possible:

Something like DarkSky or the like. Click on the component, in the upper right corner is a link to the source python file.

Create your own component and then you deal with the bugs instead of some 3rd party.

thanks - it seems to be Serial Port based - with this clarification would HA on a Raspberry Pi 3 be OK do you think? So I guess the questions are:

a) HA - can you from Python open a serial port up, set baud rate, and get data?

b) Raspberry Pi 3 - the current cost provides a USB output cable that would plug into the Vera, from which the Vera opens the serial port across it. So I guess as long as you can plug in a USB cable to the Pi then this should be ok? i.e. would just be up to question (a) regarding whether you can do serial port comms in HA/Python?

Any suggestions re an existing HA plugin/components that uses Serial Port that I could get access to the Python code to have a look at?

There is the serial port sensor

Take a look at this

And this may give you a few more ideas.

https://plus.google.com/+RoganDawes/posts/6TXHraQJMHB

Just added a more detailed version of the email I sent @mixedup:

Hope it helps others

Hi

I’m a newbie and with the help of @lolouk44 (he did all the work!!!) we managed to make it working. Now the problem is to get this script autostart when HA starts.

My steps:

shell_command:
  getcurrentcost: /FULL_PATH_TO_FILE/CurrentCost.py

Add an automation so the script starts when HA starts:

automation:
  - alias: HASS Start CurrentCost
    trigger:
      - platform: homeassistant
        event: start
    action:
    - service: shell_command.getcurrentcost

I get this error:

I’am able to run the script and receive the data from the sensor manually.

Thank you for the help.

I’m wondering if you add a 2 to 5 minute delay it may work. Maybe the automation is getting executed before the shell commands are loaded.

Hi Petro

How can I do that? Sorry for the newbieness!

Thank you very much

Look for delay:

from the example:

  - delay:
      # supports seconds, milliseconds, minutes, hours
      minutes: 1

With this syntax:

  - alias: HASS Start CurrentCost
    trigger:
      - platform: homeassistant
        event: start
    action:
    - service: shell_command.getcurrentcost
    - delay: '00:01:00'

Add the delay before the shell command not after. So that home assistant starts up, delays a minute, then executes your shell command.

Also, look in your services for the shell command you created, verify that it is there.

I have tried several aways: (this is some examples )

my shell command: (tried with and without python3)

shell_command:
  getcurrentcost: python3 /home/homeassistant/.homeassistant/python_scripts/CurrentCost.py

always this error:

Log Details (WARNING)
Tue May 01 2018 15:01:11 GMT+0100 (WEST)

Unable to find service shell_command/getcurrentcost

its been days, searching, reading and I can’t make it autostart.

thank you for the help

No, it needs to be in your action before your service:

action:
- delay: '00:01:00'
- service: shell_command.getcurrentcost

Also, I have no idea if this will work but its worth trying.

doesn’t work. thank you for your help.

Does the service appear in this drop down?

Interesting… Can you post your configuration for the shell command section? or post your whole config file?

Your services should have shell_command.getcurrentcost, if it doesn’t that’s why it’s not working.

all my config files:

Automation:
  - alias: HASS Start CurrentCost
       
    trigger:
      - platform: homeassistant
        event: start
        
    action:
    - delay: '00:01:00'
    - service: shell_command.getcurrentcost

Shell Command:

shell_command:
  getcurrentcost: python3 /home/homeassistant/.homeassistant/python_scripts/CurrentCost.py

Well I’m stumped because you should have a service named shell_command.getcurrentcost and your config looks correct.

To clarify, your shell_command section is inside your config, not inside an additional yaml file that is “included!” in your config? Only reason I ask is I want to make sure you don’t have this scenario:

config.yaml:

shell_command: inlude! shell_command.yaml

shell_command.yaml:

shell_command:
  getcurrentcost:

This would be invalid and it would produce a shell_command named shell_command.shell_command