RESTful command to external (webhook) server

Hello all,
Looking to use the RESTful command to send a command to an external webhook server to open and close the bedroom blinds at a certain time.

rest_command: 
       mbedroom_shades_up:
          url: “https://server:9443/set/xxxxxxxxxxxxx/open/12” 
          method: get 
          content_type: “text/plain” 
      mbedroom_shades_down: 
          url: “https://server:9443/set/xxxxxxxxxxxxx/favorite/12” 
          method: get 
          content_type: “text/plain”

is this the correct implementation? I know I will need to very actual indent and spacing once in the config file.

did u run it and it worked? → then yes
it didn’t? → then nope

that’s the start, unless there’s something else u’re worried about

@DvdNwk I am afraid of turning my HA (operational) unit into a brick - cause something locked it up. Yes - I have backups - but that is always dicey. Backups are good and necessary if something unforeseen happens. If I had a sandbox or safe zone to operate in, test things out, that would be another issue.

So - like to ask the collective brain (that would be all of you), is this novice on the right path, and at least a face value, nothing looks dangerous.

So - do I presume - this coding looks…generally ok? My risk - I know.
Thanks.

U won’t. Worst case scenario, the command won’t work after restart and you will have angry messages in logs.

I don’t know what’s your install type, but I’m using HA as a VM inside Proxmox – which has excellent backups – can recommend.

  1. Fix the indents (use two spaces for indents)
  2. method: get is unnecessary (it is the default according to the docs)
  3. content_type – it may be unnecessary as well (but this one u need do test)

@DvdNwk THANK YOU! Your guidance and counsel were spot on. It worked.

Code looks like

rest_command: 
  mbedroom_shades_up:
    url: "https://hghst.net:9443/set/xxxxxxxxxxxxxxxxxxx/open/12" 
    method: get 
    content_type: "text/plain" 
  mbedroom_shades_down: 
    url: "https://hghst.net:9443/xxxxxxxxxxxxxxxxxxx/favorite/12" 
    method: get 
    content_type: "text/plain"

The one problem I came across is - the quotation marks in MS Word and the quotation marks in YAML are different. Having read another unrelated HA community discussion, I recalled this comment, went back, looked real hard at my quotation marks, changed them…and WHAMO everything worked.

THANK YOU ! :smiley:

Automation solved!

WOW, u edit your yaml config in MS Word? Stop ;-O

no - no. I did the concept in MS Word…then placed in this thread. Not the actual coding for the YAML.Config file. My mistake when I was copying code from one editor to another.

Yes - I have installed and normally use Studio Code Server. Long story, I was on different computers, moving code back and forth… ugh.

All good - many thanks ! :slight_smile:

@DvdNwk On a side note, What is/are a good reference(s) to learn YAML? My search seems to reveal it is a learn as you go effort. There must be some good sources with examples

YAML as a notation/format is pretty simple: all it cares about are the indents, haha.

The more complicated thing is what to write in YAML → the domain values, what HA wants you put in YAML format.

I’m struggling here as well, even though I’m a programmer. It helps for sure to know basic programming ideas, like variables, variable types, structures, loops, conditions, etc.

Just try to learn from the docs and experiment. Google a lot. Ask here, ask on Discord.

You’ve seen REST docs, there you go: the values that you can use, examples, etc.

As for the Templates, there is additional step of yet another language inside: Jinja2.

This is REALLY helpful to experiment with Templates: http://homeassistant.local:8123/developer-tools/template

I just write snippets there and copy them wherever I need. I don’t even delete them, they serve as a future reference to something I already figured out.

Last thing, all of it is powered by Python.

A big journey, it’s programming after all. But a fun journey → especially when something is finally starting to work :smiley: Good luck :wink:

@DvdNwk Many thanks! This is very helpful and is much appreciated! Thanks ! :smiley: