davidusb-geek / emhass

emhass: Energy Management for Home Assistant, is a Python module designed to optimize your home energy interfacing with Home Assistant.
MIT License
278 stars 54 forks source link

shell command in configuration.yaml #14

Closed tomekl1978 closed 2 years ago

tomekl1978 commented 2 years ago

incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line

davidusb-geek commented 2 years ago

Hi, you should be more specific here. What is the shell command that you are trying to use? What are you trying to achieve, what kind of optimization?

tomekl1978 commented 2 years ago

Shell command from instructions in Home Assisstant.

shell_command:
  dayahead_optim: curl -i -H "Content-Type: application/json" -X POST -d '{}' http://localhost:5000/action/dayahead-optim
  publish_data: curl -i -H "Content-Type: application/json" -X POST -d '{}' http://localhost:5000/action/publish-data 
davidusb-geek commented 2 years ago

Ok, you'll need to provide more information, otherwise it'll be very hard to help you solve this. Please post the complete logs from the "Log" pane in the add-on.

This fails when running the "dayahead-optim" or the "publish_data"?

May be share you yaml add-on configuration...

davidusb-geek commented 2 years ago

Hi, just closing this as no more information was provided and impossible to solve (if it is a real issue) as it is.

henne49 commented 2 years ago

when entering the shell_command statement into Visual studio, you get the following error message displayed: incomplete explicit mapping pair; a key node is missed.

Also the check config yaml element shows: Error loading /config/configuration.yaml: mapping values are not allowed here

the provide shell code command does not work in latest home assistant 2022.8.2

davidusb-geek commented 2 years ago

Hi, I'm just reopening this issue to see if we can get somewhere on this issue. I have Home Assistant 2022.8.3 installed, the lastest version, and the shell_commands are working just fine. What I can't understand is what are you trying to achieve here, in what context this is not working? Is the EMHASS add-on loaded and running?

Maybe I can just repeat the same questions that remained unanswered with @tomekl1978:

Please post the complete logs from the "Log" pane in the add-on. This fails when running the "dayahead-optim" or the "publish_data"? May be share you yaml add-on configuration...

There is a lot of information missing here in order to try to help you.

henne49 commented 2 years ago

Got it fixed, you have to remove the space after the Content-Type: application does not work, the below commands work, please just adjust the documentation.

thx

shell_command: dayahead_optim: curl -i -H 'Content-Type:application/json' -X POST -d '{}' http://localhost:5000/action/dayahead-optim publish_data: curl -i -H "Content-Type:application/json" -X POST -d '{}' http://localhost:5000/action/publish-data

davidusb-geek commented 2 years ago

Ok perfect. Thank you.

I actually realized that the documentation was outdated, I actually implemented those shell_command using this syntax:

shell_command:
  dayahead_optim: "curl -i -H 'Content-Type: application/json' -X POST -d '{}' http://localhost:5000/action/dayahead-optim"

So I wasn't having any problem with that. And your solution is also valid I guess. I just updated the documentation

henne49 commented 2 years ago

I tried that as well, but it did not work for me. Thank you for your great tool! I was trying to find exactly what you are doing, as this is last bit to fully automate and save energy.