brianjking / homeassistant-config

Configuration for @brianjking Home Assistant
https://home-assistant.io
82 stars 8 forks source link

Feed api_pasword in to your github shell command... #134

Closed point-4ward closed 6 years ago

point-4ward commented 6 years ago

Hi Brian,

Ages ago I was looking at your repo to inspire my Maintenance package, and I just noticed you still had "TODO" next to feed password for your Github new commits sensor.

I've fixed it for you with this PR (presuming you still use it, and this isn't a reference).

Should you decide to encrypt your access with SSL at some point in the future and need to hide your URL, you could do it like this:

Script:

sequence:
  - service: shell_command.update_new_commits_sensor
    data:
      api_password: !secret http_password
      url: !secret curl_url

Shell command:

bash /home/homeassistant/.homeassistant/bin/update_new_commits_sensor.sh "{{ api_password }}" "{{ url }}"

Appropriate line in your update_new_commits_sensor.sh:

curl -X POST -H "x-ha-access: $1" -H "Content-Type: application/json" $2 -d "{\"state\": \"$commits\"}"

I can heartily recommend switching over to my maintenance package concept though :smile: - could probably knock you a personalised version up pretty quickly if you wanted?

Anyway, hope this helps ๐Ÿ™‚

๐Ÿ‘

point-4ward commented 6 years ago

Just realised - You'll need to update your 'help doc' to reflect the change at some point too.

brianjking commented 6 years ago

@mf-social Thank you so much, going to look into implementing this shortly. Have a few questions that you can hopefully help out with so I can merge your PR (#134) and update my docs.

curl -X POST -H "x-ha-access: $1" -H "Content-Type: application/json" https://my.domain.com/api/states/sensor.new_commits?api_password=MyPassword -d "{\"state\": \"$commits\"}"
point-4ward commented 6 years ago

So yeah, pass the arguments in the same manner, then $1 is the first one, $2 is the second etc.

You can pass them all as secrets, and then you don't have to manually change anything after you've pulled an update.

Hope this helps.

point-4ward commented 6 years ago

LMK if you have any issues ๐Ÿ‘