SmartThings Community

Raspberry Pi Monitor

raspberrypi
(Janos Elohazi) #1

Hi Everyone!

It’s my first SmartThings project. But based on some examples out there I came up with a Java/SpringBoot backend based monitor device handler.

https://github.com/cl0udninja/raspberrypi.smartthings

4 Likes
#2

This looks interesting. Other than the screenshot you showed, does it display any other stats? I assume this is a one-way communication to ST, but not back to the Raspberry Pi?

(Janos Elohazi) #3

Yes so far. The plan is to make my daughter’s LED Firefly string driven by a pi nano. So the next one would be to turn the LED on and off.

(PPO16) #4

Nice implementation.

I made 2 projects using the pi as a gateway to drive BTLE devices here and here and something I’d like to implement is a self discovery of the pi rather than emtering the IP and port.
I saw a ssdp development from a member that I planned report but got lazy…
Maybe you can add that too and make your dth plug and play for a ST style user experience.

(Andy) #5

Thanks for this project, I’ve been looking for something like this. I’ve set everything up, however I’m running into a problem on the RPi when I start the jar, in short port 8080 is already in use, how do you change the port your project uses?

(Janos Elohazi) #6

That’s a cool idea. I google really quickly and there’re implementations out there to implement UPnP with SpringBoot. I’ll try to add this feature!

I created an issue on GitHub for this.

1 Like
(Janos Elohazi) #7

Hi,

Thanks for checking this out! The monitor running on the Pi is a standard SpringBoot application. If you want to modify the embedded Tomcat server’s HTTP port from the default 8080 to let’s say 8081 start up the application with this command:

java -jar -Dserver.port=8081 raspberrypi.monitor.jar 
(Andy) #8

Thanks for coming back to me, that sorted the port issue and the RPi server is up & running and all is working.

(PPO16) #9

Excellent.

My personal difficulty was to define the right type of UUID. Most of the examples I saw were audio streaming cases to the developer was using a standard audio type of descriptor. Appreciate your solution and findings.
I’ll try to find again the ST member one as it was for wired alarm object and he defined many types of devices. Will check again later today if time.

(Janos Elohazi) #10

Cool, happy to hear that!

(Janos Elohazi) #11

Let me know if you find out something!

(PPO16) #12

Here you go.

(Janos Elohazi) #13

Thank you!

(Janos Elohazi) #14

I’ve added UPnP support!

1 Like
(PPO16) #15

Very good! I am checking that. Lazy me…

(Janos Elohazi) #16

I had some time finally and did a little LED nightlight control with the Pi. For the code to run on the Pi check out this link.

Here’s the device handler here and the discovery smart app here.

The code could be cleaner. Once I’ll have some more time I’ll tidy it up!

(Michael Salerno) #17

Okay hoping to get a little help here I’m having a total brain fart. I have everything setup on the Pi but need the path to the jar file I have to run and for the life of me can’t figure that out. Anyone provide any insight?

(Janos Elohazi) #18

If you check out the github repo and have maven and jdk8 installed, just run mvn clean install. The jar file is going to be created under the target folder. This folder is cleaned every time you build the project, so I suggest to move the jar file out from that location to somewhere else. Let me know if that helped!

(Michael Salerno) #19

Thanks I got it after some sleep and a cup of coffee I was able to think straight.

Next question…I have everything setup and can access the API via the web but Discovery is not finding anything in the SmartApp any thoughts?

(Janos Elohazi) #20

There’re a couple of things I could think of

  • Do you have a firewall running on the Pi? UPnP works with UDP broadcast. I think my solution uses port 5000 and it needs ports 8080 and 8081 open as well.
  • You can run the jar with java -Dlogging.level.com.cl0udninja.raspberrypi.monitor=DEBUG -jar monitor.jar to see more logging and figure out what could be wrong.

If it still doesn’t work, you can add the device manually on the ST IDE, just go to Devices/New Device for type use the Raspberry Pi Monitor and for device id you need the IP address and the port (default is 8080) in this format ip:port. You need to convert both values to Hex.

You can use this online tool for the IP: https://ncalculators.com/digital-computation/ip-address-hex-decimal-binary.htm
And this for the port: https://ncalculators.com/digital-computation/ip-address-hex-decimal-binary.htm

So if your Pi’s IP is 192.168.1.100 and the monitor runs on port 8080 the value you need to provide for Device Network Id is: C0A80164:1F90

I hope this works. If you send me the logs I could probably pinpoint what the problem is with UPnP