Writing Interface from Savant Systems

Hi,

I’m currently using Ruby to interface Savant home automation systems with Ezlo. I used PTY with cURL to handle it originally, but with the latest macOS it causes issues with forkpty where the terminal stops working after about 3 days. This is due to the constant cURL to the Ezlo for broadcasts that disconnects for some reason every 30 seconds.

I’ve rewritten all of the script to use Net::HTTPS but the broadcasts are causing me headaches. If I use cURL it works fine. If I use Net::HTTPS, it does not. I also attempted to use event machine-websockets and no joy either.

I enabled debug on a separate script that I’m using just to test accessing /v1/broadcasts and this is what I get:

#Net::HTTP::Get:0x00007ffa780b9080

opening connection to 192.168.x.x:17000…

opened

starting SSL for 192.168.x.x:17000…

SSL established

← “GET /v1/broadcasts HTTP/1.1\r\nAccept-Encoding: gzip, deflate\r\nAccept: /\r\nUser-Agent: Ruby\r\nAuthorization: Basic TOKENHERE\r\nConnection: keep-alive\r\nContent-Type: text/event-stream\r\nAccess-Control-Allow-Origin: *\r\nHost: 192.168.x.x:17000\r\n\r\n”

→ “HTTP/1.1 200 OK\r\n”

→ “content-type: text/event-stream\r\n”

→ “connection: close\r\n”

→ “access-control-allow-origin *\r\n”

Conn close because of error wrong header line format

The script tops there. It looks like the access-control-allow-origin is sent back without a colon so Ruby throws an error. Any ideas what’s going on? I’m using an Ezlo Plus Hub.

require 'net/http'
require 'net/https'
require 'uri'
require 'openssl'

request = []
$port = ":17000"
$commandURL = "https://"
$ipaddress = "192.168.x.x"
#uri = URI.parse("https://192.168.x.x:17000/v1/method/hub/items/list")
uri = URI.parse("https://192.168.x.x:17000/v1/broadcasts")
http = Net::HTTP.new(uri.host, 17000)
http.set_debug_output($stderr)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
request['authorization'] = 'Basic TOKENHERE'
request['connection'] = 'keep-alive'
request['Accept-Encoding'] = 'gzip, deflate'
request['content-type'] = 'text/event-stream'
request['Access-Control-Allow-Origin'] = '*'
puts request
response = http.request(request)
puts response
puts response.body
puts response.code

Heeeeeeelp… this is the last part I need to finish this new version… it’s kicking my ass. Can anyone from the Ezlo dev team help me out with an explanation as to why the header is invalid?

1 Like

Hello
Talking to Engineering team to get a developer who can help you.

1 Like

You can use our brand new Plugin framework to do that.

I thought the plugin framework was for Ezlo to control other devices and services? I used the HTTPS API to accomplish control from Savant to Ezlo. My currently released version polls the locks to get status. I was attempting to add broadcast support so I wouldn’t have to poll. Basically this is to get all devices setup to Ezlo into Savant from lighting to thermostats to leak sensors, door locks, etc. I have Savant dealers deploying it already but getting this broadcast subscription worked out is sorely needed.

Postman is throwing the same header error as well. If there’s something I can send in my request to fix that, that’d be great.

Sent you a PM. pls check

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules