Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team

Question
Speedo67 1
Hello guys,
for the first: english ist not my first language - sorry!
I have on HC2 a running VD to integrate a ROBONECT-modul (www.robonect.de) on HC2. Now, i am a owner of a HC3 (5.110.15) and i will change the request to HC3 Quickapp.
The running code on VD for get a http request for status looks like this:
-----------------------------------------------------------------------------------------------------------------------------------------
-- Setze Verbindungsdaten
-- hole ip adresse aus virtuellem modul
local selfId = fibaro:getSelfId()
local mowerIP = fibaro:get(selfId, "IPAddress")
local mowerPort = fibaro:get(selfId, "TCPPort")
local versuche = 3
-- setze variable MOWER aus IP und Logindaten
MOWER = Net.FHttp(mowerIP)
MOWER:setBasicAuthentication("xxxx","xxxx")
--check Onlinestatus
local function _ping(retry)
fibaro:call(selfId, "setProperty", "ui.OLStatus.value", "Starte Online-Check")
fibaro:sleep(500)
retry = retry or 0
local tcpSocket = Net.FTcpSocket(mowerIP, mowerPort)
tcpSocket:setReadTimeout(250)
--fibaro:debug('Suche..., versuche #' .. retry .. ' bitte warten...')
fibaro:sleep(250)
local bytes, errorCode = tcpSocket:write('ping')
if errorCode == 0 then
return true
else
if retry < versuche then
--fibaro:debug('Nicht gefunden, erneut versuchen, bitte warten...')
fibaro:sleep(500);
return _ping(retry + 1)
end
return false
end
end
local f, result = pcall(_ping)
if (f) then
if (result == true)
then
fibaro:debug(mowerIP.. ':' .. mowerPort .. ' wurde gefunden,')
fibaro:call(selfId, "setProperty", "ui.OLStatus.value", "Mower ist Online");
fibaro:debug("Status wird abgefragt");
fibaro:debug("Status online - starte Abfragen");
else
fibaro:debug(mowerIP.. ':' .. mowerPort .. ' wurde nicht gefunden.')
fibaro:call(selfId, "setProperty", "ui.OLStatus.value", "Mower ist Offline")
fibaro:debug("Status des Automower wird aufgrund mangelnder Erreichbarkeit nicht abgefragt")
fibaro:debug("Status wurde nicht abgefragt, warte für 5 Minuten)");
fibaro:sleep(300000)
end
else
fibaro:debug('Error: ' .. f)
end
-- geting info about specific device
response = MOWER:GET("/json?cmd=status")
--fibaro:debug(response)
-- decoding json string to table
extractedjson = json.decode(response)
-- "status/battery": "Battery Status"
-- "status/duration": "Mode Duration"
-- "status/hours": "Hours"
-- "status/mode": "Mode"
-- "status/status": "Status"
-- "timer/status": "Timer Status"
battery = extractedjson.status.battery
duration = extractedjson.status.duration
hours = extractedjson.status.hours
AM_Status = extractedjson.status.status
AM_Mode = extractedjson.status.mode
AM_Timer = extractedjson.timer.status
-- Error_ = extractedjson.error.status
--fibaro:debug(battery.."%")
--fibaro:debug(duration.."s")
--fibaro:debug(hours.."h")
--fibaro:debug(AM_Status)
--fibaro:debug(AM_Mode)
--fibaro:debug(AM_Timer)
--fibaro:debug(Error_)
fibaro:call(selfId, "setProperty", "ui.LabelBatterystatus.value",(battery).." %");
fibaro:call(selfId, "setProperty", "ui.LabelModeDuration.value",(duration).." s");
fibaro:call(selfId, "setProperty", "ui.LabelHours.value",(hours).."h");
--fibaro:call(selfId, "setProperty", "ui.LabelMode.value",(AM_Mode));
--fibaro:call(selfId, "setProperty", "ui.LabelStatus.value",(AM_Status));
--fibaro:call(selfId, "setProperty", "ui.LabelTimer.value",(AM_Timer));
--fibaro:debug("Status Auswertung gestartet")
--fibaro:debug("Autmowerstatus = "..AM_Status)
fibaro:call(selfId, "setProperty", "ui.LabelStatus.value","Check Mowerstatus");
fibaro:sleep(500)
if (AM_Status == 17) then
fibaro:call(selfId, "setProperty", "ui.LabelStatus.value"," Automower schläft");
fibaro:call(selfId, "setProperty", "currentIcon","1013");
fibaro:log("Status: Automower schläft")
fibaro:setGlobal("MowerStatus", "sleeping")
--fibaro:debug("Automower schläft")
elseif (AM_Status == 1) then
fibaro:call(selfId, "setProperty", "ui.LabelStatus.value"," Automower parkt/hat gestoppt");
fibaro:call(selfId, "setProperty", "currentIcon","1017");
fibaro:log("Status: Automower parkt")
--fibaro:debug("Automower parkt")
fibaro:setGlobal("MowerStatus", "parking")
elseif (AM_Status == 2) then
fibaro:call(selfId, "setProperty", "ui.LabelStatus.value"," Automower mäht");
fibaro:call(selfId, "setProperty", "currentIcon","1010");
fibaro:log("Status: Automower mäht")
--fibaro:debug("Automower mäht")
fibaro:setGlobal("MowerStatus", "mowing")
elseif (AM_Status == 3) then
fibaro:call(selfId, "setProperty", "ui.LabelStatus.value"," Automower sucht die Ladestation");
fibaro:call(selfId, "setProperty", "currentIcon","1014");
fibaro:log("Status: Automower sucht die Ladestation")
--fibaro:debug("Automower sucht die Ladestation")
fibaro:setGlobal("MowerStatus", "searching")
elseif (AM_Status == 4) then
fibaro:call(selfId, "setProperty", "ui.LabelStatus.value"," Automower lädt");
fibaro:call(selfId, "setProperty", "currentIcon","1016");
fibaro:log("Status: Automower lädt")
--fibaro:debug("Automower lädt")
fibaro:setGlobal("MowerStatus", "charging")
elseif (AM_Status == 5) then
fibaro:call(selfId, "setProperty", "ui.LabelStatus.value"," Automower sucht (manuell umsetzen)");
fibaro:call(selfId, "setProperty", "currentIcon","1015");
fibaro:log("Status: Automower sucht (manuell umsetzen)")
--fibaro:debug("Automower sucht (manuell umsetzen)")
elseif (AM_Status == 7) then
fibaro:call(selfId, "setProperty", "ui.LabelStatus.value"," Fehlerstatus");
fibaro:log("Status: Fehlerstatus")
--fibaro:debug("Fehlerstatus")
elseif (AM_Status == ? then
fibaro:call(selfId, "setProperty", "ui.LabelStatus.value"," Schleifensignal verloren");
fibaro:call(selfId, "setProperty", "currentIcon","1012");
fibaro:log("Status: Automower Schleifensignal verloren")
--fibaro:debug("Automower Schleifensignal verloren")
fibaro:setGlobal("MowerStatus", "lost_signal")
else
fibaro:call(selfId, "setProperty", "ui.LabelState.value"," Error");
fibaro:log("Status: Ladefehler")
--fibaro:debug("Ladefehler")
end
fibaro:setGlobal("AM_Status", AM_Status);
fibaro:call(selfId, "setProperty", "ui.LabelMode.value","Check Mowermodus");
fibaro:sleep(500);
--fibaro:debug("Modus Auswertung gestartet")
if (AM_Mode == 0) then
fibaro:call(selfId, "setProperty", "ui.LabelMode.value"," Auto");
fibaro:log("Mode: Auto")
--fibaro:debug("Auto")
fibaro:setGlobal("MowerMode", "Auto")
elseif (AM_Mode == 1) then
fibaro:call(selfId, "setProperty", "ui.LabelMode.value"," Manuell");
fibaro:log("Mode: Manuell")
--fibaro:debug("Manuell")
fibaro:setGlobal("MowerMode", "Man")
elseif (AM_Mode == 2) then
fibaro:call(selfId, "setProperty", "ui.LabelMode.value"," Home");
fibaro:log("Mode: Home")
--fibaro:debug("Home")
fibaro:setGlobal("MowerMode", "Home")
else
fibaro:call(selfId, "setProperty", "ui.LabelMode.value"," Error");
fibaro:log("Mode: Fehler")
fibaro:debug("Fehler")
end
fibaro:setGlobal("AM_Mode", AM_Mode);
fibaro:call(selfId, "setProperty", "ui.LabelTimer.value","Check Timermodus");
fibaro:sleep(500);
--fibaro:debug("Timer Auswertung gestartet")
if (AM_Timer == 0) then
fibaro:call(selfId, "setProperty", "ui.LabelTimer.value"," Deaktiviert");
fibaro:log("Timer: Deaktiviert")
--fibaro:debug("Deaktiviert")
elseif (AM_Timer == 1) then
fibaro:call(selfId, "setProperty", "ui.LabelTimer.value"," Auto");
fibaro:log("Timer: Auto")
fibaro:debug("Auto")
elseif (AM_Timer == 2) then
fibaro:call(selfId, "setProperty", "ui.LabelTimer.value"," Standby");
fibaro:log("Timer: Standby")
fibaro:debug("Standby")
else
fibaro:call(selfId, "setProperty", "ui.LabelTimer.value"," Error");
fibaro:log("Timer: Fehler")
fibaro:debug("Fehler")
end
fibaro:setGlobal("AM_Timer", AM_Timer);
----------------------------------------------------------------------------------------------------------------------
on a webbrowser i get a complete status with this:
http://<user>:<password>@<ip>:<port>/json?cmd=status
{"name": "MowerReiche", "id": "10AD57", "status": {"status": 17, "distance": 0, "stopped": false, "duration": 42067, "mode": 2, "battery": 100, "hours": 2604}, "timer": {"status": 0, "next": {"date": "2022-07-07", "time": "10:00:00", "unix": 1657188000}}, "blades": {"quality": 84, "hours": 22, "days": 15}, "wlan": {"signal": -89}, "health": {"temperature": 24, "humidity": 28}, "clock": {"date": "2022-07-07", "time": "08:20:55", "unix": 1657182055}, "successful": true}
My code for HC3 QuickApp to get a status-info:
---------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------
What notation can solve this?
0 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.