Need HTTP for curl

Hey guys, reading and reading, and been experimenting with different configurations for weeks and can’t get joy. New AT&T Fiber 1Gb (awesome), but modem will not allow port forward for port 443 to anything. I have HTTPS working with DuckDNS, but I have to enter xxx.duckdns.org:8123. Not the end of the world at first…

Well the whole reason for wanting HA was for integrations. Now, curl commands error out due to certificate issues, and getting above my head for how to correct. Don’t know enough to know how concerned I should be for security, but know that I want https outside of my local network, and http inside. I can’t make http work. NGINX needs port 443. I’m lost…

Running 111.4 and here is my latest config…

default_config:

homeassistant:
  external_url: https://xxx.duckdns.org:8123
  internal_url: http://homeassistant.local:8123

http:
  base_url: homeassistant.local:8123
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem

if I # out the ssl_certificate and ssl_key, then enables http outside my network. I know this has to be simple, but I’m stuck.

Please forgive a rookie, but need a little assistance to get to the next level

Does this help, 0.110: Is internal_url useless when https enabled?

In particular, Frenk and Petro’s replies.

Are you using curl from somewhere outside your local lan to control HA?

No, a friend on the SecuritySpy (SS) website helped me use my security cameras as motion detectors and sending curl commands to HA. Right now HTTPS is down, as I had to # out the ssl commands to make the functionality work.

If you can not make the motion detection work securely then you need to set up a reverse proxy. This will enable you to use http inside your network and you can expose home assistant via https on the external network.

Search for Nginx or Caddy. Both available as addons for home assistant.

There in lies the problem. Tried NGINX and can’t use port 443, so never could make it work. AT&T won’t release the port, as it’s built into their BGW210-700 load (per a cs rep) for TV WAP Services.

I’ll take a look at Caddy now.

I keep hearing horror stories about At&T. Do they monopolise the data provider network where you are?

No other choices?

So bit the bullet and went to Nabu Casa. Don’t like paying $5 a month while I’m in testing mode, but tired of wasting months with DuckDNS issues. Now back to the Curl issue. The whole premise was to coordinate motion detection from SecuritySpy on my Mac to send a webhook to HA.

So I’ve got 4 separate script files…

do shell script "curl -d “” “http://192.168.1.79:8123/api/webhook/driveway_ss_trigger_1"”
do shell script "curl -d “” “http://192.168.1.79:8123/api/webhook/front_porch_ss_trigger_1"”
do shell script "curl -d “” “http://192.168.1.79:8123/api/webhook/back_porch_ss_trigger_1"”
do shell script "curl -d “” “http://192.168.1.79:8123/api/webhook/garage_ss_trigger_1"”

, but only the garage script actually runs. I’ve executed the automations within HA and they function correctly, but the webhook ID doesn’t seem to be coming through except for the one mentioned. The scripts are identical except for their name, and I did try as paul2020 suggested to change the quote aspects, but with no joy.

One note, from within Script Editor, I can “play” the garage script and it functions, whereas the others will not. To me, this indicates that the curl command

I turned on logger: in my configuration.yaml file and it brought my HA to a crawl with too many entries. I changed it to…

logger: 
  default: warning
  logs: 
    homeassistant.components.automations: debug
    homeassistant.components.webhook: debug
    homeassistant.components.switch: debug

and this is all it posts…

2020-07-14 23:23:44 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for driveway_ss_trigger_1
2020-07-14 23:27:40 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for front_porch_ss_trigger_1
2020-07-14 23:35:37 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for garage_ss_trigger_1

notice that the garage_ss_trigger_1 is not a line item, yet it functions perfectly. Thoughts anyone?

There is a free month.

Why send an empty string as data?

Also you are using a bizarre form of quotes throughout. In shell scripting there is no difference between an open and close quote.

"" not “”

It could be your lack of formatting though.

This was a cut/paste from Boxgrove on SecuritySpy forum, but I think it’s something in the pasting of the quotes here. I’ve been also trying single quotes and I’ll try a few changes. As for the data, there is no data to pass. I just want that when the webhook is called to execute the automation. If I need to pass data, but that data isn’t used anywhere, then that’s fine.

but here’s the latest…

So I went into Terminal on Mac and entered the curl command, and it executed with no errors. Went back into File Editor on HA and found this line in the debug for the appropriate time stamp…

2020-07-15 00:46:20 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for driveway_ss_trigger_1

So if I’m thinking about this correctly, the curl command is getting to HA. HA is recognizing the webhook, but it is not executing. Is this because of the lack of data in the curl command? The garage_ss_trigger_1 works just fine and it’s the same syntax. I can manually execute the automation in the Configuration and it works. here is the excerpt from the automations.yaml file…

- id: '1593209500332'
  alias: ss_driveway_motion
  description: Activate lights on SS driveway camera motion
  trigger:
  - platform: webhook
    webhook_id: driveway_ss_trigger_1
  condition:
  - after: sunset
    before: sunrise
    condition: sun
  - condition: state
    entity_id: switch.shelly_shsw_1_115f00
    state: 'off'
  action:
  - device_id: e6629ba0af684d6890b50f41079b5a4d
    domain: switch
    entity_id: switch.shelly_shsw_1_115f00
    type: turn_on
  - delay: 00:10:00
  - device_id: e6629ba0af684d6890b50f41079b5a4d
    domain: switch
    entity_id: switch.shelly_shsw_1_115f00
    type: turn_off

What am I missing?

[quote=“SolarCzar, post:10, topic:207775”]

condition:
  - after: sunset
    before: sunrise

There is no time that is before sunrise and after sunset on the same day,

maybe you could use state below_horizon instead…

1 Like

[quote=“nickrout, post:11, topic:207775, full:true”]

Hmmm? I was under the impression that this would represent Night Time or when it’s dark. Ok, So how do you represent that?

condition:
  condition: state  
  entity_id: sun.sun
  state: 'below_horizon'

Ok, thanks. Let me try that and come back

You guys are the best. That was exactly what the problem was. Working like a champ. Thanks for the help

1 Like

It is probably best to remember that this refers to a day that starts at midnight and goes until midnight 24 hours later.

If you think about it, there is no period in that timespan that is both before dawn AND after sunset.

Anyway, that is the reason.

So here’s a question…where can I find the details relative to the syntax and description for items like this? In looking at the home-assistant.io website, the reference is there but not the underlying explanations and I’d like to learn.

Here: https://www.home-assistant.io/docs/scripts/conditions/#sunsetsunrise-condition

thanks guys