Posts: 1
Threads: 0
Joined: Sep 2017
Reputation:
0
Has anyone tryed to find the way how to conect to netatmos wireless valves / relay?
https://www.netatmo.com/en-US/product/energy/valves
It seems there is no API for that.Only for thermostat.
THX for answer.
Posts: 120
Threads: 24
Joined: Jul 2015
Reputation:
0
Hi, does this Integration to Netatmo still work?
If not, is there any other way to read data from Netatmo?
BR Even Sundgot.
Posts: 27
Threads: 10
Joined: Jul 2015
Reputation:
6
Please find an updated version of the script, I improved how additional modules are read.
Code: require 'ltn12'
require 'socket.http'
json = require("json")
https = require 'ssl.https'
function refresh_netatmo()
local netatmo_debug = true
local client_id = "xxx"
local client_secret = "xxx"
local username = "xxx"
local password = "xxx"
local scope = "read_station"
-- optional device_id
local device_id = "xxx"
local request_token_url = "https://api.netatmo.net/oauth2/token"
local request_device_list = "https://api.netatmo.net/api/devicelist"
local response_body = { }
local export_data = {}
if (netatmo_debug) then
alert("netatmo start")
end
local request_body = "grant_type=password&client_id=" .. client_id .."&client_secret=" .. client_secret .. "&username=" .. username .. "&password=" .. password .. "&scope=" .. scope
local body, code, hdrs, stat = https.request
{
url = request_token_url;
method = "POST";
headers =
{
["Content-Type"] = "application/x-www-form-urlencoded";
["Content-Length"] = #request_body;
};
source = ltn12.source.string(request_body);
sink = ltn12.sink.table(response_body);
}
if (code ~= 200) then
alert("netatmo auth error : "..tostring(code)..","..tostring(body))
return
end
local response_decode = json.decode(table.concat(response_body))
local access_token = response_decode.access_token
if (netatmo_debug) then
alert("netatmo token %s",access_token)
end
-- request for all devices
local request_body = "access_token=" .. access_token .. "&app_type=app_station"
-- request to limit to only one device :
-- local request_body = "access_token=" .. access_token .. "&app_type=app_station&device_id=" .. device_id
local response_body = { }
local body, code, hdrs, stat = https.request
{
url = request_device_list;
method = "POST";
headers =
{
["Content-Type"] = "application/x-www-form-urlencoded";
["Content-Length"] = #request_body;
};
source = ltn12.source.string(request_body);
sink = ltn12.sink.table(response_body);
}
if (code ~= 200) then
alert("netatmo devicelist error : "..tostring(code)..","..tostring(body))
return
end
local response_decode = json.decode(table.concat(response_body))
-- Main module
if (netatmo_debug) then
alert("netatmo main module")
end
grp.write("netatmo temperature interieure",response_decode.body.devices[1].dashboard_data.Temperature,dt.float16)
grp.write("netatmo humidite interieure",response_decode.body.devices[1].dashboard_data.Humidity,dt.scale)
grp.write("netatmo pression",response_decode.body.devices[1].dashboard_data.Pressure,dt.uint16)
grp.write("netatmo CO2",response_decode.body.devices[1].dashboard_data.CO2,dt.float16)
grp.write("netatmo sonometre",response_decode.body.devices[1].dashboard_data.Noise,dt.uint8)
grp.write("netatmo temperature interieure minimum",response_decode.body.devices[1].dashboard_data.min_temp,dt.float16)
grp.write("netatmo temperature interieure maximum",response_decode.body.devices[1].dashboard_data.max_temp,dt.float16)
grp.write("netatmo pression absolue",response_decode.body.devices[1].dashboard_data.AbsolutePressure,dt.uint16)
grp.write("netatmo salon temperature",response_decode.body.devices[1].dashboard_data.Temperature,dt.float16)
grp.write("netatmo salon humidite",response_decode.body.devices[1].dashboard_data.Humidity,dt.scale)
grp.write("netatmo salon CO2",response_decode.body.devices[1].dashboard_data.CO2,dt.uint16)
-- search for additional modules by name
for index, value in ipairs(response_decode.body.modules) do
if (netatmo_debug) then
alert("netatmo module " .. tostring(index) .. ":" .. tostring(value.module_name))
end
if (value.module_name == "Pluviomètre") then
if (netatmo_debug) then
alert("netatmo module match pluviometre")
end
grp.write("netatmo pluviometre",value.dashboard_data.Rain,dt.float16)
grp.write("netatmo pluviometre 1h",value.dashboard_data.sum_rain_1,dt.float16)
grp.write("netatmo pluviometre 24h",value.dashboard_data.sum_rain_24,dt.float16)
elseif (value.module_name == "Extérieur") then
if (netatmo_debug) then
alert("netatmo module match exterieur")
end
grp.write("netatmo temperature exterieure",value.dashboard_data.Temperature,dt.float16)
grp.write("netatmo humidite exterieure",value.dashboard_data.Humidity,dt.float16)
grp.write("netatmo temperature exterieure minimum",value.dashboard_data.min_temp,dt.float16)
grp.write("netatmo temperature exterieure maximum",value.dashboard_data.max_temp,dt.float16)
elseif (value.module_name == "Chambre") then
if (netatmo_debug) then
alert("netatmo module match Chambre")
end
grp.write("netatmo chambre temperature",value.dashboard_data.Temperature,dt.float16)
grp.write("netatmo chambre CO2",value.dashboard_data.CO2,dt.float16)
grp.write("netatmo chambre humidite",value.dashboard_data.Humidity,dt.scale)
elseif (value.module_name == "Bureau") then
if (netatmo_debug) then
alert("netatmo module match Bureau")
end
grp.write("netatmo bureau temperature",value.dashboard_data.Temperature,dt.float16)
grp.write("netatmo bureau CO2",value.dashboard_data.CO2,dt.float16)
grp.write("netatmo bureau humidite",value.dashboard_data.Humidity,dt.scale)
elseif (value.module_name == "Studio") then
if (netatmo_debug) then
alert("netatmo module match Studio")
end
grp.write("netatmo studio temperature",value.dashboard_data.Temperature,dt.float16)
grp.write("netatmo studio CO2",value.dashboard_data.CO2,dt.float16)
grp.write("netatmo studio humidite",value.dashboard_data.Humidity,dt.scale)
end
end
if (netatmo_debug) then
alert("netatmo end")
end
end
Posts: 51
Threads: 14
Joined: Jul 2015
Reputation:
1
Hello Matt, thanks for the update, works great for me. Did you by any chance also try to integrate the readings for battery levels of the modules?
Posts: 19
Threads: 9
Joined: Nov 2018
Reputation:
0
okay, so I followed the recipe, how am I able to use those data as objects?
Posts: 27
Threads: 10
Joined: Jul 2015
Reputation:
6
Quote:okay, so I followed the recipe, how am I able to use those data as objects?
If you write the value to objects you should be able to see it in the object list.
You can also script anything with netatmo value as condition.
I hope this helps.
Posts: 19
Threads: 9
Joined: Nov 2018
Reputation:
0
(30.01.2019, 20:11)Matt Wrote: Quote:okay, so I followed the recipe, how am I able to use those data as objects?
If you write the value to objects you should be able to see it in the object list.
You can also script anything with netatmo value as condition.
I hope this helps.
No values, no errors, no alerts
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
30.01.2019, 21:27
(This post was last modified: 30.01.2019, 21:28 by Erwin van der Zwart.)
Hi,
Did you create all your objects with the exact same names (including capitals) as used in line 84 to 95 and all other grp.write lines?
Try to change the names to GA’s to be sure..
Posts: 92
Threads: 16
Joined: Jan 2020
Reputation:
2
Hi.
Is this still working? I cannot create the private app from "http://dev.netatmo.com"
Its nothing that appears from that link.
Posts: 115
Threads: 23
Joined: Sep 2021
Reputation:
2
Posts: 4643
Threads: 24
Joined: Aug 2017
Reputation:
207
Add before refresh_netamo call to your library by adding require('user.netamo')
------------------------------
Ctrl+F5
Posts: 115
Threads: 23
Joined: Sep 2021
Reputation:
2
15.09.2021, 11:00
(This post was last modified: 15.09.2021, 11:00 by pioneersteffen.)
Many thanks! That was the problem! Now it works!
Posts: 60
Threads: 12
Joined: Oct 2019
Reputation:
0
API SCRIPT - WIND SPEED in Meters per Second?
Is there a simple way to change the script to show value as MS instead of km/h?
Schneider Wiser (homeLynk), Power Tags, DALI, Multitouch Pro, Panasonic Heating pump, Flexit balansed ventilation, HUE integration, Lemus Speaker system. Tibber integration.
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
11.02.2022, 00:22
(This post was last modified: 11.02.2022, 00:29 by Erwin van der Zwart.)
Code: --1 km/h to m/s = 0.28 m/s
value = 1
value = math.round(value * 5/18, 2) -- 1000/3600 = ((1000/200)/(3600/200)) = 5/18
log(value)
Posts: 60
Threads: 12
Joined: Oct 2019
Reputation:
0
Thanks a lot. I'll check it in the weekend.
Schneider Wiser (homeLynk), Power Tags, DALI, Multitouch Pro, Panasonic Heating pump, Flexit balansed ventilation, HUE integration, Lemus Speaker system. Tibber integration.
Posts: 41
Threads: 6
Joined: Jun 2017
Reputation:
1
Hello.
Do you know if there are problems with netatmo? I've been offline for two days.
I have this error: "netatmo auth error : 400.1"
Posts: 449
Threads: 94
Joined: Jun 2015
Reputation:
6
13.07.2023, 13:41
(This post was last modified: 13.07.2023, 13:54 by gjniewenhuijse.)
(13.07.2023, 09:53)iridium Wrote: Hello.
Do you know if there are problems with netatmo? I've been offline for two days.
I have this error: "netatmo auth error : 400.1"
same problem here
response_body returns: string: {"error":"unauthorized_client"}
Posts: 7758
Threads: 42
Joined: Jun 2015
Reputation:
447
Maybe there are some changes in their API. Try contacting Netatmo support.
Posts: 449
Threads: 94
Joined: Jun 2015
Reputation:
6
14.07.2023, 11:52
(This post was last modified: 14.07.2023, 12:41 by gjniewenhuijse.)
(14.07.2023, 08:46)admin Wrote: Maybe there are some changes in their API. Try contacting Netatmo support.
Maybe this?
Client credentials grant type
https://api.netatmo.com/oauth2/token
Method: POST
!! This method will be deprecated in october 2022 !!
If you want to access data from another user's account, you MUST use the Authorization code grant type.
Netatmo Connect | Authentication
For now i choose generate token with the right scope in de Netatmo My Apps window. This generates an access and refresh token. I used the access_token hardcoded in the script.
Posts: 449
Threads: 94
Joined: Jun 2015
Reputation:
6
- generate a refresh_token with the right scope in http://dev.netatmo.com under my apps and choose for Token generator
- Copy the Refresh Token to the variable refresh_token
Now every run of the function get_token refreshed the token and saved it for further use.
Code: -- get auth token from refresh token
refresh_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
function get_token()
refresh = storage.get('netatmo_refresh_1', refresh_token)
local request_body = "grant_type=refresh_token&client_id=" .. client_id .."&client_secret=" .. client_secret .. "&refresh_token=" .. refresh
local body, code, hdrs, stat = https.request
{
url = request_token_url;
method = "POST";
headers =
{
["Content-Type"] = "application/x-www-form-urlencoded";
["Content-Length"] = #request_body;
};
source = ltn12.source.string(request_body);
sink = ltn12.sink.table(response_body);
}
if (code ~= 200) then
if (netatmo_debug) then
log("netatmo auth error: "..tostring(code)..", "..tostring(body))
end
return
end
local response_decode = json.decode(table.concat(response_body))
local access_token = response_decode.access_token
if response_decode.refresh_token then
storage.set('netatmo_refresh_1', response_decode.refresh_token)
end
if (netatmo_debug) then
log(response_body)
log("netatmo token %s",access_token)
end
return "access_token=" .. access_token
end
|