In order to follow my internet access, I want to get somes values from my internet box "SFR NB6" API and store these data into Domoticz.
The API request is :
Code: Select all
http://192.168.1.1/api/1.0/?method=dsl.getInfo
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<rsp stat="ok" version="1.0">
<dsl status="up" linemode="ADSL2+" uptime="137177" counter="1" crc="0" noise_down="6.4" noise_up="9.2" attenuation_down="22.0" attenuation_up="12.0" rate_down="23619" rate_up="1023" line_status="No Defect" training="Showtime" />
</rsp>
- rate_down
- rate_up
- attenuation_down
- attenuation_up
- noise_down
- noise_up
- crc
- Counter
Could you please help me to write a dzVents script ?
My expectation is to use something similar as my below script used for Json data :
Code: Select all
local idxCloudCover = 112 -- (Integer) Device ID of device holding cloudcoverage
local idxBarometer = 113 -- (Integer) Device ID of device barometric presusure
local idxPrecipIntensity = 131 -- (Integer) Device ID of device barometric presusure
local ApiKey = '79947d33c8097e153533ce959hsjeldi' -- (string) API key for Darksky
local GPSCoordinates = '47.454062,8.846521' -- (string) City GPS coordinates (lat, long)
local Debug = true
return {
on = {
timer = { 'every 4 minutes' },
httpResponses = { 'result' }
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
--url = "https://api.openweathermap.org/data/2.5/weather?id=".. CityID .."&appid=" .. ApiKey,
url = "https://api.darksky.net/forecast/" .. ApiKey .. "/" .. GPSCoordinates,
method = 'GET',
callback = 'result'
})
elseif (item.isJSON) then
if (item.ok) then -- statusCode == 2xx
-- Read Pressure
--local pressure = item.json.main.pressure
local pressure = item.json.currently.pressure
domoticz.devices(idxBarometer).updateBarometer(domoticz.utils.round(pressure,0))
-- Read Clouds
--local CloudCover = item.json.clouds.all
local CloudCover = item.json.currently.cloudCover
CloudCover = CloudCover * 100
domoticz.devices(idxCloudCover).updatePercentage(domoticz.utils.round(CloudCover,0))
-- Read precipIntensity
local PrecipIntensity = item.json.currently.precipIntensity
PrecipIntensity = PrecipIntensity*100
domoticz.devices(idxPrecipIntensity).updateRain(domoticz.utils.round(PrecipIntensity,0))
--Debug
if (Debug == true) then
domoticz.log("pressure=" .. pressure .. "hPa")
domoticz.log("CloudCover=" .. CloudCover .. "%")
domoticz.log("precipIntensity=" .. PrecipIntensity .. "mm/h * 100")
end
end
end
end
}