Thanks - I appreciate the reply but that is way beyond me.
I got a little further and am able to call that script but get a:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/components/python_script.py", line 166, in execute
exec(compiled.code, restricted_globals, local)
File "pvoutput.py", line 5, in <module>
NameError: name 'object' is not defined
I think I will just go the CURL method and see where that gets me.
I have copied your shell command and automation, but when it runs i get the error below. Any suggestions?
2019-01-11 11:40:05 INFO (MainThread) [homeassistant.components.automation] Executing pvoupload
2019-01-11 11:40:05 INFO (MainThread) [homeassistant.helpers.script] Script pvoupload: Running script
2019-01-11 11:40:05 INFO (MainThread) [homeassistant.helpers.script] Script pvoupload: Executing step call service
2019-01-11 11:40:05 ERROR (MainThread) [homeassistant.components.shell_command] Error rendering command template: UndefinedError: ‘None’ has no attribute ‘state’
Traceback (most recent call last):
File “/usr/src/app/homeassistant/helpers/template.py”, line 138, in async_render
return self._compiled.render(kwargs).strip()
File “/usr/local/lib/python3.6/site-packages/jinja2/asyncsupport.py”, line 76, in render
return original_render(self, *args, **kwargs)
File “/usr/local/lib/python3.6/site-packages/jinja2/environment.py”, line 1008, in render
return self.environment.handle_exception(exc_info, True)
File “/usr/local/lib/python3.6/site-packages/jinja2/environment.py”, line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File “/usr/local/lib/python3.6/site-packages/jinja2/_compat.py”, line 37, in reraise
raise value.with_traceback(tb)
File “<template>”, line 1, in top-level template code
File “/usr/src/app/homeassistant/helpers/template.py”, line 446, in forgiving_round
value = round(float(value), precision)
jinja2.exceptions.UndefinedError: ‘None’ has no attribute ‘state’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/src/app/homeassistant/components/shell_command.py”, line 54, in async_service_handler
rendered_args = args_compiled.async_render(service.data)
File “/usr/src/app/homeassistant/helpers/template.py”, line 140, in async_render
raise TemplateError(err)
homeassistant.exceptions.TemplateError: UndefinedError: ‘None’ has no attribute ‘state’
I’m no HA/python expert, but that sounds like you don’t have a value associated with what you’re trying to put in the curl command. Have you made sure the value works in the templating area in HA?
thankyou for the quick response. No, i have not setup a value nor tested anything in the templating area. This is my first foray into curl/automation. Back to the doco i go
As an update to this, I made a couple of modifications to my automation as to only upload when my internet is ‘online’ (heaps of internet drop outs in our 3rd world internet here in Australia).
In addition to that, sometimes I get an error “homeassistant.exceptions.TemplateError: UndefinedError: ‘None’ has no attribute ‘state’”, even when there is a state. My solution is to wait 10 seconds and then try again, with an almost 100% success rate (before the double-up I would get 1-3 missed uploads a day).
I was looking for this too and I am happy I found this solution. I don;t like my API key in the YAML files though as I use Github so I did this to template the API key:
I am using two commands as I have a cumulative energy usage value from my smart meter and a power generation value from the solar power invertor. (note: the c1=1 means cumulative)
Hi Didier,
I am testing Home assistant for the first time and i am struggling trying to use the description you posted.
I input the portion sensor and shell_command into configuration.yaml . The API and system id into the file secret.yalm
Checking the file configuration.yaml system says it is OK …no errors… but how to run every 5 minutes the command to upload data to PVOUTPUT?
Would be very appreaciated a support from you.
So I got the API working fine thanks to your posts above, however I’m a bit confused how I create a 5min average sensor to send to PVoutput.
I have a template sensor that calculates my instantaneous house consumption (removing solar generation):
Awesome, thanks for that example. Based on that I’ve got a functioning configuration for a Fronius inverter. The config below uploads all the standard fields, including consumption, voltage, temperature etc. So if anyone else adapts this for there fronius choose which fields you want to upload, v1 and v3 are the essential ones I believe.
Note to deal with the ‘unknown’ state from a sensor in some circumstances the powerflow is set to default to 0, if it’s unable to be rounded.