Home Assistant v2.0.1 (#50)
* fix(*): Added a function to remove trailing slashes from URLs. * feat(panel): Added a home assistant icon alongsite the panel tile. * chore(plugin): Bump the version to 2.0.1 * fix(panel): Fixed wrong glyph syntax.
This commit is contained in:
+10
-4
@@ -1,10 +1,15 @@
|
||||
--!nonstrict
|
||||
|
||||
local haUrl = noctalia.getConfig("ha_url")
|
||||
local haUrlRaw = noctalia.getConfig("ha_url")
|
||||
local haToken = noctalia.getConfig("ha_token")
|
||||
|
||||
local MANAGED_ENTITIES_FILE = "managed_entities.json"
|
||||
|
||||
local function getCleanUrl()
|
||||
if type(haUrlRaw) ~= "string" then return "" end
|
||||
return (haUrlRaw:gsub("/$", ""))
|
||||
end
|
||||
|
||||
local function loadManagedEntities()
|
||||
local dataDir, dirErr = noctalia.pluginDataDir()
|
||||
if not dataDir then
|
||||
@@ -49,13 +54,14 @@ local function syncUpdateInterval()
|
||||
end
|
||||
|
||||
local function isConfigured()
|
||||
return haUrl and haUrl ~= "" and getCleanToken() ~= ""
|
||||
local url = getCleanUrl()
|
||||
return url and url ~= "" and getCleanToken() ~= ""
|
||||
end
|
||||
|
||||
local function haRequest(endpoint, method, body, callback)
|
||||
if not isConfigured() then return false end
|
||||
|
||||
local url = haUrl .. endpoint
|
||||
local url = getCleanUrl() .. endpoint
|
||||
local cleanToken = getCleanToken()
|
||||
|
||||
local jsonBody
|
||||
@@ -296,7 +302,7 @@ function startSSEStream()
|
||||
return false
|
||||
end
|
||||
|
||||
local url = haUrl .. "/api/stream?restrict=state_changed"
|
||||
local url = getCleanUrl() .. "/api/stream?restrict=state_changed"
|
||||
|
||||
noctalia.log("Starting SSE stream")
|
||||
currentEvent = { data = "", event = "" }
|
||||
|
||||
Reference in New Issue
Block a user