debsahu / harestapi Goto Github PK
View Code? Open in Web Editor NEWAn Arduino library to talk to Home Assistant using Rest API made for ESP8266.
License: GNU General Public License v3.0
An Arduino library to talk to Home Assistant using Rest API made for ESP8266.
License: GNU General Public License v3.0
Hello,
great work and thanks a lot for that!
i have this error 'sendGetHA' was not declared in this scope
and dont understand what is wrong...the 'sendGetHA' is red, like recognize as a function,
what i am doing wrong please? i just call the function like
sendGetHA(URL, messageURL);
where URL and messageURL as define as String in global variable at the beginning of the skecth..;
If you could help,
thanks
when compiling the code i got this error
C:\Users\yoann\Documents\Arduino\libraries\HARestAPI-0.3\src\HARestAPI.cpp: In member function 'String HARestAPI::sendGetHA(String)': C:\Users\yoann\Documents\Arduino\libraries\HARestAPI-0.3\src\HARestAPI.cpp:103:21: error: 'class BearSSL::WiFiClientSecure' has no member named 'verify' 103 | if (wsclient->verify(_fingerprint.c_str(), _serverip.c_str())) | ^~~~~~ C:\Users\yoann\Documents\Arduino\libraries\HARestAPI-0.3\src\HARestAPI.cpp: In member function 'bool HARestAPI::sendPostHA(String, String)': C:\Users\yoann\Documents\Arduino\libraries\HARestAPI-0.3\src\HARestAPI.cpp:200:21: error: 'class BearSSL::WiFiClientSecure' has no member named 'verify' 200 | if (wsclient->verify(_fingerprint.c_str(), _serverip.c_str())) | ^~~~~~ exit status 1 Erreur de compilation pour la carte LOLIN(WEMOS) D1 mini (clone)
Hey @debsahu,
I would really like to use this library in a project i;m working on but i'm having no luck getting it to connect to my home assistant install.
I'm trying to run the example sketch you have and ii have filled in everything needed, WIFI details and password, Home Assistant long lived token, fingerprint, port etc, but ultimately i get a connection failed message
Here is the output in the serial console:
connecting to SKYA92CD
.......
WiFi connected
IP address:
192.168.86.19
Requesting URL: /api/services/light/toggle
Sending:
POST /api/services/light/toggle HTTP/1.1
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.*********************************************
Content-Type: application/json
Content-Length: 26
{"entity_id":"light.lamp"}
Connecting to b4zm62u2sem***************.ui.nabu.casa
connection failed
`
I'm using nabu casa, but I'm not sure that matter as I have used the same details in https://reqbin.com/ and that triggers fine
Any help you can offer here would be great.
Please let me know if you need anything further
Thank you
Joe
When uses sendCustomHAData every request couses heap corruption. It present in 0.3, but 0.2 ok,
Sadly the lib is broken :-(
.pio\libdeps\nodemcuv2\HARestAPI\src\HARestAPI.cpp: In member function 'String HARestAPI::sendGetHA(String)':
.pio\libdeps\nodemcuv2\HARestAPI\src\HARestAPI.cpp:102:21: error: 'class BearSSL::WiFiClientSecure' has no member named 'verify'
102 | if (wsclient->verify(_fingerprint.c_str(), _serverip.c_str()))
| ^~~~~~
.pio\libdeps\nodemcuv2\HARestAPI\src\HARestAPI.cpp: In member function 'bool HARestAPI::sendPostHA(String, String)':
.pio\libdeps\nodemcuv2\HARestAPI\src\HARestAPI.cpp:201:21: error: 'class BearSSL::WiFiClientSecure' has no member named 'verify'
201 | if (wsclient->verify(_fingerprint.c_str(), _serverip.c_str()))
| ^~~~~~
Compiling .pio\build\nodemcuv2\libc1a\ESP8266mDNS\LEAmDNS_Structs.cpp.o
*** [.pio\build\nodemcuv2\lib17d\HARestAPI\HARestAPI.cpp.o] Error 1
Hi,
Great work on this library!
Is it correct that you are using the HTTP api password to authenticate?
If so, will you change this so it rather uses the long lived access-tokens?
Ref: https://www.home-assistant.io/docs/authentication/providers/#legacy-api-password
I am a fan of using releases instead of master, but realised there are some typos?
Compile errors:
...\HARestAPI.cpp:102:53: error: expected ';' before '}' token
102 | wsclient->setFingerprint(_fingerprint.c_str())
| ^
| ;
103 | }
| ~
...\HARestAPI.cpp: In member function 'bool HARestAPI::sendPostHA(String, String)':
...\HARestAPI.cpp:191:54: error: expected ';' before '}' token
191 | wsclient-> setFingerprint(_fingerprint.c_str())
| ^
| ;
192 | }
| ~
After fixing those manually, everything worked fine.
C:\Users\conkhidan\Documents\Arduino\libraries\HARestAPI-master\src\HARestAPI.cpp: In member function 'String HARestAPI::sendGetHA(String, String)':
C:\Users\conkhidan\Documents\Arduino\libraries\HARestAPI-master\src\HARestAPI.cpp:82:15: error: expected primary-expression before '=' token
posturl + = "Authorization: Bearer " + _password + "\r\n"; //long-lived password
^
C:\Users\conkhidan\Documents\Arduino\libraries\HARestAPI-master\src\HARestAPI.cpp:83:13: error: expected primary-expression before '=' token
posturl + = "Content-Type: application/json" + "\r\n" +
^
C:\Users\conkhidan\Documents\Arduino\libraries\HARestAPI-master\src\HARestAPI.cpp:83:52: error: invalid operands of types 'const char [31]' and 'const char [3]' to binary 'operator+'
posturl + = "Content-Type: application/json" + "\r\n" +
^
C:\Users\conkhidan\Documents\Arduino\libraries\HARestAPI-master\src\HARestAPI.cpp: In member function 'bool HARestAPI::sendPostHA(String, String)':
C:\Users\conkhidan\Documents\Arduino\libraries\HARestAPI-master\src\HARestAPI.cpp:158:15: error: expected primary-expression before '=' token
posturl + = "Authorization: Bearer " + _password + "\r\n"; //long-lived password
^
C:\Users\conkhidan\Documents\Arduino\libraries\HARestAPI-master\src\HARestAPI.cpp:159:13: error: expected primary-expression before '=' token
posturl + = "Content-Type: application/json" + "\r\n" +
^
C:\Users\conkhidan\Documents\Arduino\libraries\HARestAPI-master\src\HARestAPI.cpp:159:52: error: invalid operands of types 'const char [31]' and 'const char [3]' to binary 'operator+'
posturl + = "Content-Type: application/json" + "\r\n" +
^
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
For reading the payload, it is necessary to read the content-length header to know the length of the payload.
The payload does not necessarily end with \r\n so you cannot read it with readString().
If the payload ist not terminated with \r\n, the program hangs at
replystr = wclient->readString();
until it gets a timeout after 1000s.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.