Using a node.js module (node-robonect-api) for accessing robonect events in a Home Automation Scenario

Du möchtest Deinen Automower in Deine Hausautomatisierung einbinden oder eine eigene App entwicklen?
Hier wird diese offene Schnittstelle zum Robonect Hx Modul beschrieben.

Moderator: Lampi

Cloud
Forum-Nutzer
Beiträge: 16
Registriert: Sa 17. Jun 2017, 13:12
Wohnort: München
Mäher: Gardena R70Li
Firmware des Mähers (MSW): MSW 6.xx.xx
Herstellungsjahr: 2016
Robonect-Modul: Robonect Hx (Rev.4)
Robonect Firmware: V.0.0 18.06.2017

Re: Using a node.js module (node-robonect-api) for accessing robonect events in a Home Automation Scenario

Beitrag von Cloud »

Thats what i got:

Code: Alles auswählen

pi@raspberrypi:~ $ cd ~/node_modules/node-robonect-api&&npm update
pi@raspberrypi:~/node_modules/node-robonect-api $ 
pi@raspberrypi:~/node_modules/node-robonect-api $ npm ls|grep robonect
node-robonect-api@0.0.1 (git://github.com/allan-gam/node-robonect-api.git#95abbb52f6a1a263ccc96fdbaf7af94172c2420e) /home/pi/node_modules/node-robonect-api

msan
Forum-Nutzer
Beiträge: 19
Registriert: Fr 12. Mai 2017, 12:30
Wohnort: Sweden
Mäher: Husqvarna Automower 420
Firmware des Mähers (MSW): MSW 7.xx.xx
Herstellungsjahr: 2016
Robonect-Modul: Robonect Hx (Rev.3)
Robonect Firmware: V1.0 Beta 3

Re: Using a node.js module (node-robonect-api) for accessing robonect events in a Home Automation Scenario

Beitrag von msan »

can you try

Code: Alles auswählen

npm update git+https://github.com/allan-gam/node-robonect-api.git
Then check the version.

In case it doesn't work, please also try this:

Code: Alles auswählen

npm update git://github.com/allan-gam/node-robonect-api.git
Then check the version.

If it's still on 0.0.1, can you please try this:

Code: Alles auswählen

cd ~/node_modules&&rm -rf node-robonect-api
npm install git://github.com/allan-gam/node-robonect-api.git
Thanks!

Cloud
Forum-Nutzer
Beiträge: 16
Registriert: Sa 17. Jun 2017, 13:12
Wohnort: München
Mäher: Gardena R70Li
Firmware des Mähers (MSW): MSW 6.xx.xx
Herstellungsjahr: 2016
Robonect-Modul: Robonect Hx (Rev.4)
Robonect Firmware: V.0.0 18.06.2017

Re: Using a node.js module (node-robonect-api) for accessing robonect events in a Home Automation Scenario

Beitrag von Cloud »

Thank you for your fast help, im happy to help testing :) I got the new version with the last set of commands:

Code: Alles auswählen

pi@raspberrypi:~ $ npm update git+https://github.com/allan-gam/node-robonect-api.git
pi@raspberrypi:~ $ npm ls|grep robonect
├─┬ node-robonect-api@0.0.1 (git://github.com/allan-gam/node-robonect-api.git#95abbb52f6a1a263ccc96fdbaf7af94172c2420e)
pi@raspberrypi:~ $ npm update git://github.com/allan-gam/node-robonect-api.git
pi@raspberrypi:~ $ npm ls|grep robonect
├─┬ node-robonect-api@0.0.1 (git://github.com/allan-gam/node-robonect-api.git#95abbb52f6a1a263ccc96fdbaf7af94172c2420e)
pi@raspberrypi:~ $ cd ~/node_modules&&rm -rf node-robonect-api
pi@raspberrypi:~/node_modules $ npm install git://github.com/allan-gam/node-robonect-api.git
-
> ref@1.3.3 install /home/pi/node_modules/node-robonect-api/node_modules/net-keepalive/node_modules/ref
> node-gyp rebuild

make: Entering directory '/home/pi/node_modules/node-robonect-api/node_modules/net-keepalive/node_modules/ref/build'
  CXX(target) Release/obj.target/binding/src/binding.o
  SOLINK_MODULE(target) Release/obj.target/binding.node
  COPY Release/binding.node
make: Leaving directory '/home/pi/node_modules/node-robonect-api/node_modules/net-keepalive/node_modules/ref/build'

> ffi@2.2.0 install /home/pi/node_modules/node-robonect-api/node_modules/net-keepalive/node_modules/ffi
> node-gyp rebuild

make: Entering directory '/home/pi/node_modules/node-robonect-api/node_modules/net-keepalive/node_modules/ffi/build'
  CC(target) Release/obj.target/ffi/deps/libffi/src/prep_cif.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/types.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/raw_api.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/java_raw_api.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/closures.o
  CC(target) Release/obj.target/ffi/deps/libffi/src/arm/ffi.o
../deps/libffi/src/arm/ffi.c: In function ‘ffi_prep_args’:
../deps/libffi/src/arm/ffi.c:72:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    && vi < ecif->cif->vfp_nargs && vfp_type_p (*p_arg))
          ^
../deps/libffi/src/arm/ffi.c: In function ‘ffi_prep_incoming_args_SYSV’:
../deps/libffi/src/arm/ffi.c:335:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    && vi < cif->vfp_nargs && vfp_type_p (*p_arg))
          ^
../deps/libffi/src/arm/ffi.c: In function ‘layout_vfp_args’:
../deps/libffi/src/arm/ffi.c:750:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (i = 0; i < cif->nargs; i++)
                 ^
  CC(target) Release/obj.target/ffi/deps/libffi/src/arm/sysv.o
  AR(target) Release/obj.target/deps/libffi/libffi.a
  COPY Release/libffi.a
  CXX(target) Release/obj.target/ffi_bindings/src/ffi.o
../src/ffi.cc: In static member function ‘static void FFI::InitializeBindings(Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE)’:
../src/ffi.cc:111:153: warning: ‘bool v8::Object::ForceSet(v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’ is deprecated (declared at /home/pi/.node-gyp/7.10.0/include/node/v8.h:2955): Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   target->ForceSet(Nan::New<String>("RTLD_NEXT").ToLocalChecked(), WrapPointer((char *)RTLD_NEXT), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
                                                                                                                                                         ^
../src/ffi.cc:114:159: warning: ‘bool v8::Object::ForceSet(v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’ is deprecated (declared at /home/pi/.node-gyp/7.10.0/include/node/v8.h:2955): Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   target->ForceSet(Nan::New<String>("RTLD_DEFAULT").ToLocalChecked(), WrapPointer((char *)RTLD_DEFAULT), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
                                                                                                                                                               ^
../src/ffi.cc:123:167: warning: ‘bool v8::Object::ForceSet(v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’ is deprecated (declared at /home/pi/.node-gyp/7.10.0/include/node/v8.h:2955): Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   target->ForceSet(Nan::New<String>("FFI_ARG_SIZE").ToLocalChecked(), Nan::New<Uint32>((uint32_t)sizeof(ffi_arg)), static_cast<PropertyAttribute>(ReadOnly|DontDelete));
                                                                                                                                                                       ^
../src/ffi.cc:124:171: warning: ‘bool v8::Object::ForceSet(v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’ is deprecated (declared at /home/pi/.node-gyp/7.10.0/include/node/v8.h:2955): Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   target->ForceSet(Nan::New<String>("FFI_SARG_SIZE").ToLocalChecked(), Nan::New<Uint32>((uint32_t)sizeof(ffi_sarg)), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
                                                                                                                                                                           ^
../src/ffi.cc:125:171: warning: ‘bool v8::Object::ForceSet(v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’ is deprecated (declared at /home/pi/.node-gyp/7.10.0/include/node/v8.h:2955): Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   target->ForceSet(Nan::New<String>("FFI_TYPE_SIZE").ToLocalChecked(), Nan::New<Uint32>((uint32_t)sizeof(ffi_type)), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
                                                                                                                                                                           ^
../src/ffi.cc:126:169: warning: ‘bool v8::Object::ForceSet(v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’ is deprecated (declared at /home/pi/.node-gyp/7.10.0/include/node/v8.h:2955): Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   target->ForceSet(Nan::New<String>("FFI_CIF_SIZE").ToLocalChecked(), Nan::New<Uint32>((uint32_t)sizeof(ffi_cif)), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
                                                                                                                                                                         ^
../src/ffi.cc:132:148: warning: ‘bool v8::Object::ForceSet(v8::Local<v8::Value>, v8::Local<v8::Value>, v8::PropertyAttribute)’ is deprecated (declared at /home/pi/.node-gyp/7.10.0/include/node/v8.h:2955): Use CreateDataProperty / DefineOwnProperty [-Wdeprecated-declarations]
   target->ForceSet(Nan::New<String>("HAS_OBJC").ToLocalChecked(), Nan::New<Boolean>(hasObjc), static_cast<PropertyAttribute>(ReadOnly | DontDelete));
                                                                                                                                                    ^
  CXX(target) Release/obj.target/ffi_bindings/src/callback_info.o
  CXX(target) Release/obj.target/ffi_bindings/src/threaded_callback_invokation.o
  SOLINK_MODULE(target) Release/obj.target/ffi_bindings.node
  COPY Release/ffi_bindings.node
make: Leaving directory '/home/pi/node_modules/node-robonect-api/node_modules/net-keepalive/node_modules/ffi/build'
node-robonect-api@0.9.0 node-robonect-api
├── xml2js@0.4.17 (sax@1.2.2, xmlbuilder@4.2.1)
└── net-keepalive@0.3.8 (bindings@1.2.1, ms@0.7.1, ref-struct@1.1.0, debug@2.2.0, nan@2.4.0, ref@1.3.3, ffi@2.2.0)
pi@raspberrypi:~/node_modules $ npm ls|grep robonect
├─┬ node-robonect-api@0.9.0 (git://github.com/allan-gam/node-robonect-api.git#656d06d6a558653c6a93b01fae783787687f933c)
pi@raspberrypi:~/node_modules $ 

msan
Forum-Nutzer
Beiträge: 19
Registriert: Fr 12. Mai 2017, 12:30
Wohnort: Sweden
Mäher: Husqvarna Automower 420
Firmware des Mähers (MSW): MSW 7.xx.xx
Herstellungsjahr: 2016
Robonect-Modul: Robonect Hx (Rev.3)
Robonect Firmware: V1.0 Beta 3

Re: Using a node.js module (node-robonect-api) for accessing robonect events in a Home Automation Scenario

Beitrag von msan »

Cloud hat geschrieben: Di 20. Jun 2017, 11:02 Thank you for your fast help, im happy to help testing :) I got the new version with the last set of commands:
Thanks again for your kind help. I will update the installation instructions accordingly.

Cheers!

Cloud
Forum-Nutzer
Beiträge: 16
Registriert: Sa 17. Jun 2017, 13:12
Wohnort: München
Mäher: Gardena R70Li
Firmware des Mähers (MSW): MSW 6.xx.xx
Herstellungsjahr: 2016
Robonect-Modul: Robonect Hx (Rev.4)
Robonect Firmware: V.0.0 18.06.2017

Re: Using a node.js module (node-robonect-api) for accessing robonect events in a Home Automation Scenario

Beitrag von Cloud »

No problem, thats the smallest i can do. I understand some of the script but it takes me testing and googling to know how it really comes together :lol: .

I have the following error with the new StatusCode feature:

Code: Alles auswählen

/home/pi/node_modules/node-robonect-api/robonect.js:36
			self.emit("responseStatusCode", response.statusCode);
			                                        ^

TypeError: Cannot read property 'statusCode' of undefined
    at Request._callback (/home/pi/node_modules/node-robonect-api/robonect.js:36:44)
    at self.callback (/home/pi/node_modules/request/request.js:188:22)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:191:7)
    at Request.onRequestError (/home/pi/node_modules/request/request.js:884:8)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:191:7)
    at Socket.socketErrorListener (_http_client.js:358:9)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)

msan
Forum-Nutzer
Beiträge: 19
Registriert: Fr 12. Mai 2017, 12:30
Wohnort: Sweden
Mäher: Husqvarna Automower 420
Firmware des Mähers (MSW): MSW 7.xx.xx
Herstellungsjahr: 2016
Robonect-Modul: Robonect Hx (Rev.3)
Robonect Firmware: V1.0 Beta 3

Re: Using a node.js module (node-robonect-api) for accessing robonect events in a Home Automation Scenario

Beitrag von msan »

Cloud hat geschrieben: Di 20. Jun 2017, 11:22 ...
I have the following error with the new StatusCode feature:
...
In version 0.9.1 I've added a test for the existence of that property. I've also updated the Installation instruction a bit when it comes to updating.

Cloud
Forum-Nutzer
Beiträge: 16
Registriert: Sa 17. Jun 2017, 13:12
Wohnort: München
Mäher: Gardena R70Li
Firmware des Mähers (MSW): MSW 6.xx.xx
Herstellungsjahr: 2016
Robonect-Modul: Robonect Hx (Rev.4)
Robonect Firmware: V.0.0 18.06.2017

Re: Using a node.js module (node-robonect-api) for accessing robonect events in a Home Automation Scenario

Beitrag von Cloud »

Hi msan,

i have an other question regarding Domoticz, Its the first time i try to read virtual text devices in blockly events but i cant get it to work. How did you do it?
1.PNG
1.PNG (52.06 KiB) 3773 mal betrachtet

msan
Forum-Nutzer
Beiträge: 19
Registriert: Fr 12. Mai 2017, 12:30
Wohnort: Sweden
Mäher: Husqvarna Automower 420
Firmware des Mähers (MSW): MSW 7.xx.xx
Herstellungsjahr: 2016
Robonect-Modul: Robonect Hx (Rev.3)
Robonect Firmware: V1.0 Beta 3

Re: Using a node.js module (node-robonect-api) for accessing robonect events in a Home Automation Scenario

Beitrag von msan »

Cloud hat geschrieben: Do 22. Jun 2017, 10:52 Hi msan,

i have an other question regarding Domoticz, Its the first time i try to read virtual text devices in blockly events but i cant get it to work. How did you do it?

1.PNG
Hi @Cloud! I've never used blockly.

In a normal LUA script you can access a virtual Text Device's value like this:

Code: Alles auswählen

otherdevices_svalues["MY TEXT DEVICE"]
In dzVents LUA scripts you can do

Code: Alles auswählen

domoticz.devices['MY TEXT DEVICE'].state
I believe that if you post your question at http://www.domoticz.com/forum/ you'll get an answer.

Cheers!

Mosvold
Forum-Nutzer
Beiträge: 17
Registriert: Fr 28. Jul 2017, 13:50
Wohnort: Norwegen
Mäher: Husqvarna Automower 430X
Firmware des Mähers (MSW): MSW 7.xx.xx
Herstellungsjahr: 2016
Robonect-Modul: Robonect Hx (Rev.4)
Robonect Firmware: 1.2

Re: Using a node.js module (node-robonect-api) for accessing robonect events in a Home Automation Scenario

Beitrag von Mosvold »

Hi.
I got my Robonect today and now starting on the Domoticz.
I have followed your readme as best I could, but not sure what I have missed.
First I have noticed that "node" is "v0.12.1" and Not "v8.2.1" as in DaveJ guide. (I am on RPi 2, Does it matter?)

Then I have created the virtual text devices and updated script with devices and ip for robonect.
Then when I run the script i get:

Code: Alles auswählen

/home/pi/domoticz/scripts/js/mymowerscript.js:49
robonect.on('responseStatusCode', (statusCode) => {
                                                ^
SyntaxError: Unexpected token >
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:935:3
What am I missing?
OleG

msan
Forum-Nutzer
Beiträge: 19
Registriert: Fr 12. Mai 2017, 12:30
Wohnort: Sweden
Mäher: Husqvarna Automower 420
Firmware des Mähers (MSW): MSW 7.xx.xx
Herstellungsjahr: 2016
Robonect-Modul: Robonect Hx (Rev.3)
Robonect Firmware: V1.0 Beta 3

Re: Using a node.js module (node-robonect-api) for accessing robonect events in a Home Automation Scenario

Beitrag von msan »

Mosvold hat geschrieben: Fr 28. Jul 2017, 21:22 What am I missing?
Hi Mosvold!

It's hard to say but if your node version is v0.12.1 I believe that's where you should look for the problem.

First check that You have followed DaveJ's guide. Look for the heading that says Install Node.js.

What did the command

Code: Alles auswählen

uname -m
tell you?

Could you successfully add Debian apt package repository to include the NodeSource packages? Check with command:

Code: Alles auswählen

cat /etc/apt/sources.list.d/nodesource.list
It should output something like

Code: Alles auswählen

deb https://deb.nodesource.com/node_8.x jessie main
deb-src https://deb.nodesource.com/node_8.x jessie main
Did You successfully run

Code: Alles auswählen

sudo apt install nodejs
Cheers!

Antworten

Zurück zu „API für Robonect® Hx“