use tunnel in production

This commit is contained in:
2023-01-14 18:38:27 +02:00
parent d5b8d83096
commit 2a5d7de326
2 changed files with 12 additions and 6 deletions

View File

@ -13,16 +13,22 @@ class Entity < ApplicationRecord
def type
ha_id.split(".").first.capitalize
end
def self.ha_entities
res = response()
res.collect{|i| i["entity_id"]}.select{|i| i.include?("4a") || i.include?("2d")}
end
def self.response(path = "")
token = Rails.application.credentials[:ha_token]
all = RestClient.get( "10.30.39.238:8123/api/states#{path}" ,
{"Authorization" => "Bearer #{token}" })
res = JSON.parse(all.body)
host = Rails.credentials.weather_dev
host = Rails.credentials.weather_pro if Rails.env.production?
token = Rails.application.credentials.weather_token
begin
all = RestClient.get( "#{host}:8123/api/states#{path}" ,
{"Authorization" => "Bearer #{token}" })
res = JSON.parse(all.body)
rescue
[]
end
end
end