Page 1 of 2
New API Netatmo
Posted: Sunday 21 January 2024 19:43
by homeJLB
I'm working on refactoring the Netatmo Hardware. But I run in to a problem.
I'm sending
Code: Select all
std::string pName = " " + moduleName + " - Sig. + Bat. Lvl";
Debug(DEBUG_HARDWARE, "Parse Name %s - %d", pName.c_str(), moduleID );
SendPercentageSensor(moduleID, 1, batteryLevel, mrf_percentage, pName );
I also put a line in SendPercentageSensor
Code: Select all
Debug(DEBUG_HARDWARE,"DefaultName = %s", defaultname.c_str());
the logs shown;
Code: Select all
Debug: Netatmo: Parse Name Thermostaat Tuinhuis - Sig. + Bat. Lvl - 12
Debug: Netatmo: DefaultName = Thermostaat Tuinhuis - Sig. + Bat. Lvl
Debug: Netatmo: m_Name Netatmo
Debug: Netatmo: moduleName Thermostaat Tuinhuis
Netatmo: General/Percentage ( - Sig. + Bat. Lvl)
so what am I missing here, why is the Name not completely tranfered ?
Re: New API Netatmo
Posted: Sunday 21 January 2024 21:29
by homeJLB
Apparently I dit something wrong with the 'moduleID'
Changed to
Code: Select all
SendPercentageSensor(crcId, 1, batteryLevel, mrf_percentage, pName );
seems to work
Re: New API Netatmo
Posted: Sunday 28 January 2024 19:02
by homeJLB
OK so when I use the main weather device with dashboard information, the values are not correctly parsed in Domoticz.
Now I have used a different crcId for each device and the value's are correct in Domoticz but there is a creation off multiple extra empty devices

- Domoticz.png (80.96 KiB) Viewed 3083 times
But I don't find the upstream function to change this
For me personal it is not a issue to have these empty unused devices but to publicly distribute this is not acceptable
white my changed the plugin is from 16 devices to 52 used devices
kind regards
Jurgen
Re: New API Netatmo
Posted: Monday 29 January 2024 8:38
by gizmocuz
Looking good!
I assume each device has also a unique ID?
One way you could update the sensors is to call make a function like this:
Code: Select all
uint64_t CNetatmo::UpdateValueInt(int HardwareID, const char* ID, unsigned char unit, unsigned char devType, unsigned char subType, unsigned char signallevel, unsigned char batterylevel, int nValue,
const char* sValue, std::string& devname, bool bUseOnOffAction, const std::string& user)
{
uint64_t DeviceRowIdx = m_sql.UpdateValue(HardwareID, 0, ID, unit, devType, subType, signallevel, batterylevel, nValue, sValue, devname, bUseOnOffAction, (!user.empty()) ? user.c_str() : m_Name.c_str());
if (DeviceRowIdx == (uint64_t)-1)
return -1;
if (m_bOutputLog)
{
std::string szLogString = RFX_Type_Desc(devType, 1) + std::string("/") + std::string(RFX_Type_SubType_Desc(devType, subType)) + " (" + devname + ")";
Log(LOG_NORM, szLogString);
}
m_mainworker.sOnDeviceReceived(m_HwdID, DeviceRowIdx, devname, nullptr);
m_notifications.CheckAndHandleNotification(DeviceRowIdx, m_HwdID, ID, devname, unit, devType, subType, nValue, sValue);
m_mainworker.CheckSceneCode(DeviceRowIdx, devType, subType, nValue, sValue, "MQTT Auto");
return DeviceRowIdx;
}
Here you can parse the real ID
Re: New API Netatmo
Posted: Monday 05 February 2024 19:16
by homeJLB
yes each device has a unique ID that is now used for the crcID calculation.
I was thinking off using the bridge as ID that result in the same crcID
But I will look into your proposal.
For other people who want to try this;
You must make a new token whit the new URL
Code: Select all
https://api.netatmo.com/oauth2/authorize?client_id=<CLIENT_ID>&redirect_uri=http://localhost/netatmo&state=teststate&scope=read_station%20read_smarther%20write_smarther%20read_thermostat%20write_thermostat%20read_camera%20write_camera%20read_doorbell%20read_presence%20write_presence%20read_homecoach%20read_carbonmonoxidedetector%20read_smokedetector
I also recommend to make a new App int the
so you can easily change between version/tokens.
Re: New API Netatmo
Posted: Monday 05 February 2024 19:35
by homeJLB
@gizmocuz
What code do you recommend for the Events from door-sensors/co2-sensors/smokedetectors/camera's to Domoticz?
I'm just using the "message" as text.
Code: Select all
id:""
type:"movement"
time:1707156385
module_id:""
message:"<b>Beweging</b> gedetecteerd"
snapshot:
vignette:
video_id:
video_status:"available"
subevents:[
{
id:""
type:"vehicle"
time:1707135233
verified:true
offset:0
snapshot:
vignette:
message:"Auto gezien"
/code]
Re: New API Netatmo
Posted: Sunday 11 February 2024 22:48
by homeJLB
now with the auto-discovery code
The Hardware keeps on 'Unknown?'
And the Air Quality sensor keeps on reporting '48' instead of 512 ppm in this example.
The Debug_log reports the correct value.
Code: Select all
Debug(DEBUG_HARDWARE, "(%d) %s (%s) [%s] %s %s %d %d", Hardware_int, Hardware_ID.c_str(), pchar_ID, name.c_str(), sValue.c_str(), m_Name.c_str(), rssiLevel, batValue);
//pTypeAirQuality, sTypeVoc using for co2
UpdateValueInt(Hardware_int, pchar_ID, 0, pTypeAirQuality, sTypeVoc, rssiLevel, batValue, '0', sValue.c_str(), name, 0, m_Name);
Code: Select all
Debug: Netatmo: (1344664178) 70:ee:50:25:f2:72 (1081876248) [Lars] 512 Netatmo 1 255
Netatmo: Air Quality/Voc (Lars)

- unknown.png (31.72 KiB) Viewed 2891 times
Re: New API Netatmo
Posted: Thursday 15 February 2024 21:27
by homeJLB
UPDATE;
I now have almost all of my devices showing correct values in Domoticz.
The problem with the co2 value was that Domoticz expected a nvalue and I was given it a svalue .
Only with the thermostat I still have some issues.
Log shows;
Code: Select all
Status: Warning: Notification NOT handled (Hardware: 2 - Netatmo, ID: 237041147, Unit: 0, Type: 40 - Thermostat 1, SubType: 0 - Digimax), please report on GitHub!

- correct domoticz.jpg (51.75 KiB) Viewed 2858 times
Possible not correct device/parsing.
Code: Select all
int roomID
std::string roomNetatmoID
int rssiLevel
int batValue
int room_measured
const char* sValue
std::string roomName
std::string m_name
UpdateValueInt(roomID, roomNetatmoID.c_str(), 0, pTypeThermostat1, sTypeDigimax, rssiLevel, batValue, room_measured, sValue, roomName, 0, m_Name);
I will look further.
Kind regards
Jurgen
Re: New API Netatmo
Posted: Saturday 17 February 2024 16:10
by homeJLB
I find it strange that when using pType and sType mentioned in hardwarerypes.h
There is a LOG-statement of not correct device?
Also in Helper.cpp;
line 1096
Code: Select all
|| ((dType == pTypeSetpoint) && (dSubType == sTypeSetpoint))
is this duplicate off;
line 1117
Code: Select all
|| ((dType == pTypeSetpoint) && (dSubType == sTypeSetpoint))
can the Error come from this duplicate statement?
Code: Select all
Status: Warning: Notification NOT handled (Hardware: 2 - Netatmo, ID: 237041147, Unit: 0, Type: F2 - Setpoint, SubType: 16 - Unknown), please report on GitHub!
kind regards.
Re: New API Netatmo
Posted: Saturday 17 February 2024 21:44
by homeJLB
The wind sensor is not correct displayed in weather tab;

- Wind 2.png (32.56 KiB) Viewed 2827 times
In the devices page it is displayed correctly;

- wind 1.png (28.92 KiB) Viewed 2827 times
Both off the files are present in the www/images Folder.
Kind regards
Re: New API Netatmo
Posted: Saturday 17 February 2024 23:26
by waltervl
The related hardware gateway seems deleted for these devices (ID Unknown?) Then they are greyed out. Do you have more devices like that ? Perhaps they are not enabled (green arrow) but connected to your Netatmo hardware gateway?
Re: New API Netatmo
Posted: Sunday 18 February 2024 11:31
by homeJLB
With my changes to the NEW API and using Auto-discovery all the devices are like that. even with blue arrow.
But I was referring to the icon from the wind Device.
The log states;
Code: Select all
2024-02-18 11:25:03.677 Netatmo: Temp + Humidity + Baro/Weather Station (Weather Station)
2024-02-18 11:25:03.679 Netatmo: Air Quality/Voc (Weather Station)
2024-02-18 11:25:03.681 Netatmo: General/Sound Level (Weather Station)
2024-02-18 11:25:03.684 Netatmo: Temp + Humidity/LaCrosse TX3 (Buiten)
2024-02-18 11:25:03.686 Netatmo: Temp + Humidity/LaCrosse TX3 (Module Boven)
2024-02-18 11:25:03.689 Netatmo: Air Quality/Voc (Module Boven)
2024-02-18 11:25:03.691 Netatmo: Temp + Humidity/LaCrosse TX3 (Module Badkamer)
2024-02-18 11:25:03.693 Netatmo: Air Quality/Voc (Module Badkamer)
2024-02-18 11:25:03.696 Netatmo: Rain/RainByRate (Regenmeter)
2024-02-18 11:25:03.699 Netatmo: Wind/Weather Station (Windmeter)
2024-02-18 11:25:04.103 Netatmo: Temp + Humidity + Baro/Weather Station (Slaapkamer)
2024-02-18 11:25:04.104 Netatmo: Air Quality/Voc (Slaapkamer)
2024-02-18 11:25:04.106 Netatmo: General/Sound Level (Slaapkamer)
2024-02-18 11:25:04.110 Netatmo: Temp + Humidity + Baro/Weather Station (meisjes)
2024-02-18 11:25:04.112 Netatmo: Air Quality/Voc (meisjes)
2024-02-18 11:25:04.114 Netatmo: General/Sound Level (meisjes)
2024-02-18 11:25:04.117 Netatmo: Temp + Humidity + Baro/Weather Station (Lars)
2024-02-18 11:25:04.120 Netatmo: Air Quality/Voc (Lars)
2024-02-18 11:25:04.122 Netatmo: General/Sound Level (Lars)
2024-02-18 11:25:05.031 Netatmo: General/Text (Buiten - Bridge)
2024-02-18 11:25:05.031 Netatmo: General/Text (Module Boven - Bridge)
2024-02-18 11:25:05.032 Netatmo: General/Text (Module Badkamer - Bridge)
2024-02-18 11:25:05.032 Netatmo: General/Text (Regenmeter - Bridge)
2024-02-18 11:25:05.033 Netatmo: General/Text (Windmeter - Bridge)
2024-02-18 11:25:05.033 Netatmo: General/Text (Woonkamer - Bridge)
2024-02-18 11:25:05.036 Netatmo: Light/Switch/Switch (Woonkamer - Boost)
2024-02-18 11:25:05.039 Netatmo: Light/Switch/Switch (Woonkamer - Boost)
2024-02-18 11:25:05.039 Netatmo: General/Text (Lars 2 - Bridge)
2024-02-18 11:25:05.040 Netatmo: General/Text (Meisjes 3 - Bridge)
2024-02-18 11:25:05.040 Netatmo: General/Text (Slaapkamer 1 - Bridge)
2024-02-18 11:25:05.041 Netatmo: General/Text (Thermostaat Tuinhuis - Bridge)
2024-02-18 11:25:05.043 Netatmo: Light/Switch/Switch (Thermostaat Tuinhuis - Boost)
2024-02-18 11:25:05.046 Netatmo: Light/Switch/Switch (Thermostaat Tuinhuis - Boost)
2024-02-18 11:25:05.047 Netatmo: General/Text (Deur - Bridge)
2024-02-18 11:25:05.048 Netatmo: General/Text (Deur - Status)
2024-02-18 11:25:05.050 Netatmo: Light/Switch/Switch (Deur - Status)
2024-02-18 11:25:05.051 Netatmo: General/Text (Raam Slaapkamer - Bridge)
2024-02-18 11:25:05.052 Netatmo: General/Text (Raam Slaapkamer - Status)
2024-02-18 11:25:05.054 Netatmo: Light/Switch/Switch (Raam Slaapkamer - Status)
2024-02-18 11:25:05.055 Netatmo: General/Text (Raam Badkamer - Bridge)
2024-02-18 11:25:05.056 Netatmo: General/Text (Raam Badkamer - Status)
2024-02-18 11:25:05.058 Netatmo: Light/Switch/Switch (Raam Badkamer - Status)
2024-02-18 11:25:05.060 Netatmo: General/Text (AchterDeur - Bridge)
2024-02-18 11:25:05.060 Netatmo: General/Text (AchterDeur - Status)
2024-02-18 11:25:05.063 Netatmo: Light/Switch/Switch (AchterDeur - Status)
2024-02-18 11:25:05.064 Netatmo: General/Text (RaamLiving - Bridge)
2024-02-18 11:25:05.064 Netatmo: General/Text (RaamLiving - Status)
2024-02-18 11:25:05.067 Netatmo: Light/Switch/Switch (RaamLiving - Status)
2024-02-18 11:25:05.068 Netatmo: General/Text (RaamSpeelkamer - Bridge)
2024-02-18 11:25:05.068 Netatmo: General/Text (RaamSpeelkamer - Status)
2024-02-18 11:25:05.071 Netatmo: Light/Switch/Switch (RaamSpeelkamer - Status)
2024-02-18 11:25:05.072 Netatmo: General/Text (Dubbele Deur met Raam - Bridge)
2024-02-18 11:25:05.072 Netatmo: General/Text (Dubbele Deur met Raam - Status)
2024-02-18 11:25:05.075 Netatmo: Light/Switch/Switch (Dubbele Deur met Raam - Status)
2024-02-18 11:25:05.077 Netatmo: Temp/LaCrosse TX3 (Lars)
2024-02-18 11:25:05.078 Netatmo: General/Text (Lars_Setpoint)
2024-02-18 11:25:05.079 Netatmo: General/Setpoint (Lars_Setpoint)
2024-02-18 11:25:05.080 Netatmo: General/Text (Lars_Mode)
2024-02-18 11:25:05.081 Netatmo: General/Text (Lars)
2024-02-18 11:25:05.083 Netatmo: Temp/LaCrosse TX3 (Woonkamer)
2024-02-18 11:25:05.084 Netatmo: General/Text (Woonkamer_Setpoint)
I'm currently working on the messages from the events for co2/smoke-detectors and the Thermostat setpoint to show up correctly.
Kind regards
Re: New API Netatmo
Posted: Sunday 18 February 2024 20:06
by waltervl
New Netatmo API and Auto discovery?????
I think you are mixing up things here.
Re: New API Netatmo
Posted: Monday 19 February 2024 19:38
by homeJLB
The "old integration" uses for example the "SendPercentageSensor".
For the "new integration" I'm trying to use "UpdateValueInt"
But with this the Hardware is "Unknown?"
maybe I'm missing something.
I think the icon not showing up correctly is something different than the 'Unknown-hardware" and the New API from Netatmo.
Kind regards
Re: New API Netatmo
Posted: Saturday 24 February 2024 13:09
by homeJLB
Hello,
I found my fault in the code about the "Unknown ? " Hardware.
I will change this.

- wind 3.png (51.02 KiB) Viewed 2730 times
But still the Wind sensor is not correctly displayed.

- Wind 4.png (25.08 KiB) Viewed 2730 times
Kind regards
Jurgen
Re: New API Netatmo
Posted: Saturday 24 February 2024 15:27
by homeJLB
Apparently after a rebuild to 15974 the Wind sensor is displayed correctly.

- Wind 5.png (95.86 KiB) Viewed 2724 times

- Netatmo.png (146.45 KiB) Viewed 2724 times
Now all the sensors are in Domoticz
The send to Hardware / integration of the Thermostat still needs some work.
But for my usecase this is no priority.
Kind regards
Re: New API Netatmo
Posted: Sunday 10 March 2024 9:07
by homeJLB
Hello,
I was working on the setpoint off the thermostat.
But I got something weird.
Code: Select all
Netamo: Setpoint ()
Status: User: domoticz initiated a SetPoint command
Error: Netamo: NetatmoThermostat : No thermostat found in online devices!
Debug: Netamo: NetatmoThermostat idx = 4
Debug: Netamo: NetatmoThermostat idx = 4
Netamo: Setpoint (Unknown)
Status: User: domoticz initiated a SetPoint command
Error: Netamo: NetatmoThermostat : No thermostat found in online devices!
Debug: Netamo: NetatmoThermostat idx = 4
Debug: Netamo: NetatmoThermostat idx = 4
Netamo: Setpoint (Unknown)
Status: User: domoticz initiated a SetPoint command
Error: Netamo: NetatmoThermostat : No thermostat found in online devices!
Debug: Netamo: NetatmoThermostat idx = 4
Debug: Netamo: NetatmoThermostat idx = 4
Netamo: Setpoint (Unknown)
Status: User: domoticz initiated a SetPoint command
Error: Netamo: NetatmoThermostat : No thermostat found in online devices!
Debug: Netamo: NetatmoThermostat idx = 4
Debug: Netamo: NetatmoThermostat idx = 4
so the action off the 4 different setpoints returns always in idx = 4 ?
and after the action there are 4 new setpoint devices??
I was thinking the idx is always unique/singular.

- setpoint.png (69.37 KiB) Viewed 2665 times
Is there some registration off the setpoint necessary that I don't see?
Any advice on to identify the correct thermostat setpoint ?
or an example off a thermostat that uses updatevalueint().
Code: Select all
void CNetatmo::SetSetpoint(int idx, const float temp) //, const std::string& defaultname) //, std::string roomNetatmoID)
{
//Check if still connected to the API
//connect to it if needed
if (!m_isLogged == true)
{
if (!Login())
return;
}
Debug(DEBUG_HARDWARE, "NetatmoThermostat idx = %d", idx);
//Temp to set
float tempDest = temp;
unsigned char tSign = m_sql.m_tempsign[0];
// convert back to Celsius
if (tSign == 'F')
tempDest = static_cast<float>(ConvertToCelsius(tempDest));
//We change the setpoint for one hour
time_t now = mytime(nullptr);
struct tm etime;
localtime_r(&now, &etime);
time_t end_time;
int isdst = etime.tm_isdst;
bool goodtime = false;
while (!goodtime)
{
etime.tm_isdst = isdst;
etime.tm_hour += 1;
end_time = mktime(&etime);
goodtime = (etime.tm_isdst == isdst);
isdst = etime.tm_isdst;
if (!goodtime)
localtime_r(&now, &etime);
}
std::vector<std::string> ExtraHeaders;
std::string sResult;
std::stringstream sstr;
std::stringstream bstr;
Json::Value root; // root JSON object
std::string home_data = "";
bool ret = false;
bool bRet; //Parsing status
if (m_energyType != NETYPE_ENERGY)
{
// Check if thermostat device is available
if ((m_thermostatDeviceID[idx].empty()) || (m_thermostatModuleID[idx].empty())) // (m_thermostatDeviceID[roomNetatmoID].empty())
{
Log(LOG_ERROR, "NetatmoThermostat : No thermostat found in online devices!");
Debug(DEBUG_HARDWARE, "NetatmoThermostat idx = %d", idx);
return;
}
Get_Respons_API(NETYPE_SETTHERMPOINT, sResult, home_data, bRet, root);
}
else
{
//find module id
std::string module_ID = m_thermostatDeviceID[idx]; // (m_thermostatDeviceID[roomNetatmoID];
if (module_ID.empty())
{
Log(LOG_ERROR, "NetatmoThermostat: No thermostat or valve found in online devices!");
return;
}
Get_Respons_API(NETYPE_SETROOMTHERMPOINT, sResult, home_data, bRet, root);
}
if (!bRet)
{
Log(LOG_ERROR, "NetatmoThermostat: Error setting setpoint!");
return;
}
//Retrieve new thermostat data
GetHomeStatusDetails();
//Set up for updating thermostat data when the set point reach its end
m_tSetpointUpdateTime = time(nullptr) + 60;
m_bForceSetpointUpdate = true;
}
Kind Regards
Jurgen
Re: New API Netatmo
Posted: Wednesday 13 March 2024 22:26
by homeJLB
I have found the problem with the return of setsetpoint;
It is returning DeviceID and not idx.
sinds my id's are off "04:00:00:1a:47:3a" it was returning only 04
Code: Select all
unsigned long ID;
std::stringstream s_strid;
s_strid << std::hex << sd[1];
s_strid >> ID;
pGateway->SetSetpoint(ID, TempValue);
where sd[1] = std::string "04:00:00:1a:47:3a"
I like the format of the DeviceID for good reading and reference, but what is best accepted ?
Kind Regards
Re: New API Netatmo
Posted: Thursday 11 April 2024 22:44
by homeJLB
Why is there a conversion from identifying the Device ?
for example;
MAIN SwitchLight idx:41 cmd:Set Level lvl:20
MAIN SwitchLightInt : switchcmd:Set Level level:20 HWid:2 sd:2 04:00:00:1e:84:a8 2 244 62 18 Verwarming
so in the first the IDX is used for identifying and in the following function the DeviceID is used ?
must this not always be the IDX
Kind Regards
Re: New API Netatmo
Posted: Monday 10 June 2024 9:59
by benedict
Freakin' netatmo changed their API *again*, sigh.