basic integration of entities to profile
This commit is contained in:
@ -3,7 +3,6 @@ class Entity < ApplicationRecord
|
||||
|
||||
validates :name , presence: true
|
||||
validates :ha_id , presence: true
|
||||
validates :ha_type , presence: true
|
||||
validates :member_id , presence: true
|
||||
|
||||
def value
|
||||
@ -11,6 +10,10 @@ class Entity < ApplicationRecord
|
||||
@data["state"]
|
||||
end
|
||||
|
||||
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")}
|
||||
@ -20,6 +23,6 @@ class Entity < ApplicationRecord
|
||||
token = Rails.application.credentials[:ha_token]
|
||||
all = RestClient.get( "10.30.39.238:8123/api/states#{path}" ,
|
||||
{"Authorization" => "Bearer #{token}" })
|
||||
JSON.parse(all.body)
|
||||
res = JSON.parse(all.body)
|
||||
end
|
||||
end
|
||||
|
@ -6,8 +6,8 @@ class Member < ApplicationRecord
|
||||
|
||||
mount_uploader :picture, PictureUploader
|
||||
|
||||
has_many :entity
|
||||
|
||||
has_many :entities
|
||||
|
||||
def admin
|
||||
true
|
||||
end
|
||||
|
Reference in New Issue
Block a user