jamesbarnett91 / tplink-energy-monitor

An energy monitoring dashboard for TP-Link smart plugs
GNU General Public License v3.0
462 stars 102 forks source link

Error Running on Raspberry Pi 3 #16

Open dietpiuser opened 5 years ago

dietpiuser commented 5 years ago

root@raspberrypi:/home/pi/tplink# ./tplink-monitor-linux -su: ./tplink-monitor-linux: cannot execute binary file: Exec format error

root@raspberrypi:/home/pi/tplink# sudo ./tplink-monitor-linux ./tplink-monitor-linux: 1: ./tplink-monitor-linux: Syntax error: "(" unexpected

I've got the following Raspberry PI model: root@raspberrypi:/home/pi/tplink# sudo lshw | more raspberrypi description: ARMv7 Processor rev 4 (v7l) product: Raspberry Pi 3 Model B Plus Rev 1.3 serial: **** width: 32 bits capabilities: smp

root@raspberrypi:/home/pi/tplink# cat /sys/firmware/devicetree/base/model Raspberry Pi 3 Model B Plus Rev 1.3

ghost commented 5 years ago

I would guess that the executable is compiled for 64 bit cpus.

It may be possible to have it released as 32 bit as well.

ghost commented 5 years ago

Actually, more importantly, it’s probably compiled for x86, not ARM processors!

You or someone else would need to compile it separately for ARM equipped machines.

jamesbarnett91 commented 5 years ago

Hi, ballachango is correct. The pre-compiled binaries are for x86 only.

The easiest way to get it running on a Pi would be to install NodeJS, clone the repo and run the project directly via npm.

I do have a docker image for ARMv7 devices which I was using a while ago, but haven't pushed it to docker hub. I'll update it and push it out so you can run via docker as well if you have that set up on your Pi. I'll comment on this issue when its done.

dietpiuser commented 5 years ago

Thanks James.

I think the easiest option would be to setup Node JS and run it via NPM.

I will give it a go and let you know.

The idea is to be able to run it on a very low power device like the Pi as opposed to having to power a whole machine chewing up a lot more power just to collect these stats.

-------- Original message -------- From: James Barnett notifications@github.com Date: 3/12/18 11:50 pm (GMT+10:00) To: jamesbarnett91/tplink-energy-monitor tplink-energy-monitor@noreply.github.com Cc: dietpiuser fazeel11@hotmail.com, Author author@noreply.github.com Subject: Re: [jamesbarnett91/tplink-energy-monitor] Error Running on Raspberry Pi 3 (#16)

Hi, ballachango is correct. The pre-compiled binaries are for x86 only.

The easiest way to get it running on a Pi would be to install NodeJS, clone the repo and run the project directly via npmhttps://github.com/jamesbarnett91/tplink-energy-monitor#node--npm.

I do have a docker image for ARMv7 devices which I was using a while ago, but haven't pushed it to docker hub. I'll update it and push it out so you can run via docker as well if you have that set up on your Pi. I'll comment on this issue when its done.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jamesbarnett91/tplink-energy-monitor/issues/16#issuecomment-443699313, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlNx37uQYteLaulbSkTpPgEmVxm3oxWgks5u1R4ugaJpZM4Y9Siq.

dietpiuser commented 5 years ago

Hey James,

Got it all working on the raspberry Pi using Node JS and NPM.

I created a service file and it automatically starts on boot as well.

Also, how do I keep up to date with the latest version and how do I update the current one on the Pi as I can see you've got plans to add cost metrics to it as well. That would be awrsome.

Thanks again for your help.

Regards, Fazeel


From: Fazeel Peerboccus fazeel11@hotmail.com Sent: Tuesday, 4 December 2018 11:45 PM To: jamesbarnett91/tplink-energy-monitor; jamesbarnett91/tplink-energy-monitor Cc: Author Subject: Re: [jamesbarnett91/tplink-energy-monitor] Error Running on Raspberry Pi 3 (#16)

Thanks James.

I think the easiest option would be to setup Node JS and run it via NPM.

I will give it a go and let you know.

The idea is to be able to run it on a very low power device like the Pi as opposed to having to power a whole machine chewing up a lot more power just to collect these stats.

-------- Original message -------- From: James Barnett notifications@github.com Date: 3/12/18 11:50 pm (GMT+10:00) To: jamesbarnett91/tplink-energy-monitor tplink-energy-monitor@noreply.github.com Cc: dietpiuser fazeel11@hotmail.com, Author author@noreply.github.com Subject: Re: [jamesbarnett91/tplink-energy-monitor] Error Running on Raspberry Pi 3 (#16)

Hi, ballachango is correct. The pre-compiled binaries are for x86 only.

The easiest way to get it running on a Pi would be to install NodeJS, clone the repo and run the project directly via npmhttps://github.com/jamesbarnett91/tplink-energy-monitor#node--npm.

I do have a docker image for ARMv7 devices which I was using a while ago, but haven't pushed it to docker hub. I'll update it and push it out so you can run via docker as well if you have that set up on your Pi. I'll comment on this issue when its done.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jamesbarnett91/tplink-energy-monitor/issues/16#issuecomment-443699313, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AlNx37uQYteLaulbSkTpPgEmVxm3oxWgks5u1R4ugaJpZM4Y9Siq.

jamesbarnett91 commented 5 years ago

Hey Fazeel Assuming you got the source code via git, the easiest way would just be to run a git pull periodically to get the latest changes (and then do a npm install, npm start).

If you just downloaded the source code zip to get the changes, its worth changing it to run via git. You don't need any privs or anything, should just be able to run git clone https://github.com/jamesbarnett91/tplink-energy-monitor.git

Thanks!

fabianoriccardi commented 5 years ago

Thank you, also I've just installed this app on Raspberry Pi 1 (ARMv6), it works!

runeix commented 5 years ago

@dietpiuser and @jamesbarnett91

James thanks for your work on the code for this, way better than the tplink app.

Any chance either of you could help me out with the systemd set up? I'm running it on a raspberry pi 3b+ which is serving double duty with homekit which requires me to restart it sometimes, so it would be great to have the logging for the plugs restart too.

Thanks!

ghost commented 5 years ago

I'm guessing you need a service file?

I'm not a nodejs user, but this works with the compiled app (at least until recently) on gentoo: File: /etc/systemd/system/tplink-logger.service

[Unit]
Description=TP-Link HS110 Logger service
After=network.target remote-fs.target nss-lookup.target

[Service]
User=tplink
Group=tplink
Type=simple
Restart=on-failure
ExecStart=/srv/tplink-logger/launcher.sh
TimeoutStopSec=30

[Install]
WantedBy=multi-user.target

/srv/tplink-logger/launcher.sh then contains the commands you would usually run to get your tplink logger going.

There is a bit more groundwork to do if you want to use a separate user like I have, and you'll need to know the basics of systemd with respect to starting/stopping/enabling services.

See how you go!

Vlasko commented 4 years ago

I have installed this project on my Pi 3 using git, and have had quite a lot of success using it so far. However I am a bit confused about how to stop the script. Currently I am using npm start to start it, and crtl+Z to stop it.

When I try to start the script up again, I get the following error message. Which implies to me that I am not terminating the script properly as the 3000 channel is still engage. I am quite new to running Node.js at all, so bare with me!

Error: listen EADDRINUSE: address already in use :::3000 at Server.setupListenHandle [as _listen2] (net.js:1277:14) at listenInCluster (net.js:1325:12) at Server.listen (net.js:1412:7) at Function.serverListen [as listen] (/home/pi/Projects/electricity-upload/tplink-energy-monitor/node_modules/express-ws/lib/index.js:42:40) at Object.<anonymous> (/home/pi/Projects/electricity-upload/tplink-energy-monitor/app.js:42:5) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3)

ghost commented 4 years ago

Hi Vlasko,

Ctrl+Z is to suspend a task, if you type 'jobs' at the console you'll see a list of suspended tasks. You can restart them in the foreground (taking over your console again) using 'fg [number]', or continue the task in the background using 'bg [number]'.

If you want to terminate a task, use Ctrl+C.

Vlasko commented 4 years ago

Thank you v much, I knew I had probably made a simple error

chuckenglehart commented 3 years ago

While looking to run on a Pi 2 with Buster, I ran across this as the main source of info for running on a pi so I figured I would recap what I did to get it running. 1) $ git clone https://github.com/jamesbarnett91/tplink-energy-monitor && cd tplink-energy-monitor 2) Install Node.js, wasn't included with my install. I use apt, you can use apt-get or whatever else $ sudo apt update && sudo apt upgrade -y $ sudo apt install -y nodejs $ sudo apt install -y npm 3) Then I saw some errors with Node.js version numbers, so npm got updated $ sudo npm install npm@latest -g
4) $ npm install 5) $ npm start 6) Verified that the dashboard worked, then created a service for it: $ cat /lib/systemd/system/tplink.service [Unit] Description=TPLink Energy Monitor After=network.target StartLimitIntervalSec=0 [Service] Type=simple User=pi Restart=always RestartSec=1 WorkingDirectory=/path/to/tplink-energy-monitor/ ExecStart=npm start [Install] WantedBy=multi-user.target

7) Reload, enable and start service $ sudo systemctl daemon-reload $ sudo systemctl enable tplink.service $ sudo systemctl start tplink.service 8) Reboot the system and make sure everything comes back up