Cell/Mobile phone integration with open hab

Imagine you are on holiday and your electricity breaks down. Then all your food etc my turn bad. In this case it would be nice to get a notice. This means also that the router will go down…

So my Idea is to connect a phone and then have a backup battery for the rpi, and then make the phone text me if the power goes out. In addition I have my door phone, so if someone ring my doorbell when I am not home I can make the phone call me and when i pick up my personal phone I can talk to the one that are on my door.

Also if my mum or friends drop by they can send and sms with a given code and then it can open the door lock.

Since it seems hard to run spotify on rpi, i can then also use the phone to play spotify, since i can then have this connected to my stereo.

So is it is possible todo this with openhab?

Have anyone thought about the same?

SMS notification is already available, but I recommend getting access to a sms-sending provider. (I send my messages using the API at Plivo.com)

You could have the backup battery (UPS) notify openHAB about the power outage that triggers the message sending, and a new message if it comes back up within a short time (battery capacity).

I will go for a solution that keeps both my internet router & openHAB running on backup batteries.

Calling functionality, perhaps you could have a look at the Asterisk binding: https://github.com/openhab/openhab/wiki/Asterisk-Binding

Door locking, dont know if the security class implementation has matured to be ready for this? Search for “security class implementation” in the forum…

Also if my mum or friends drop by they can send and sms with a given code and then it can open the door lock - This would require dependencies for communicating with either a API both directions with a dedicated number, or a more complex phone/microcontroller with a sim-card solution communicating with openHAB.

“Anything is possible” :smile:

Takker Frode,
Seems like plivo is offered in Norway even for two way communication.

This means I could use that to send sms to open the door as well. The rule file would then look like

rule sms received
     if received SMS
         if smsString=("1111")
  end rule

The only problem is if internet provider gets down, i can not open the door. If i had a phone the sms would still work.
for calling i could use the asterix or voip.

The spotify however still need a phone though…

So i thought the easiest would be to just get a prepaid phone card and throw a phone connected to the usb on RPI in there

Bare hyggelig Kim.

Would probably be less complex to have a fallback solution with 3g/4g usb dongle connected to your internet router than building complex connections to a mobile phone.

Spotify playback via a cell phone, sounds like a hacky configuration. I use Sonos myself that already have a binding. But I believe i’ve seen blog posts about playing Spotify on the Pi. What about Mopidy?

Still, myself I would avoid tangling too much up to the Pi running openHAB…

Using spotify on a phone and connected to the stereo(3.5mm stereo) is something heaps of people do and in my experience .

How is that a hacky configuration? So I can be on my laptop, phone or whatever and I can select songs there and then spotify will automatically play it on that phone that are connected to the stereo. yes sonos is nice, but a bit pricy…

So my idea was to only have openhab on the pi, especially since the soundcard on the pi is not the best…

I found this link
that might be doable…

Would the phone be temporary or permanently connected as a spotify player?

Permanently, I will put it in my fuse box together with the rpi and relays. I already have 3.5mm cable from the fuse box to the stereo.

If you already have battery backup, why not have your network on the battery backup as well?

Look into the Tasker plugin for Android. It can receive the SMS and communicate with openHAB over the REST API, as well as so much more.

To my knowledge just plugging in a phone via USB to a computer isn’t going to do much for you for communication. I think the best you can do is have something on the phone drop a file and something on your computer poll the folder for new files. Of course this means setting up something like Tasker or your own custom code on the phone.

It would indeed be a whole lot easier to get a 3G/4G modem like @fuglestad suggests.

I assume you mean you cannot open the door automatically. You should always have a manual way to override/implement your automation.

I will look into it, but one of the reason to use a phone was the ability to use spotify and also make a phone call when someone rings the doorbell and I am not home. I was hoping simple at commands would be possible through usb on an android phone.

Yes I can open the door by key or sendcommand(doorLock,On) command

A smart phone isn’t a modem. It is a whole computer in its own right so without some extra software written for both it and the computer it is plugged into a USB link between the two will not do any more than plugging two laptops together with a USB cable.

AT commands

I just assumed you were working with a stock phone, not a rooted one. Once rooted a whole world of opportunities open up. But my statement still stands that you need software on the computer, in this case adb.

I never tried to run a self contained adb command or script, I’ve always done it interactive. Can you just pass it a command or a script like you can do with ssh or bash?

Is it safe to store a cellphone with lithium battery (I assume) inside the fuse box?

Let me propose a totally different approach for the notification on power down.

When things get bad, you should assume they’ll be even worse than you envisionned.

So instead of trusting that backup power will still work, and that all the pieces of the system will be functional (rasp pi + communication), you should assume that everything went dark. Dark as in “not an electron moves in your toys” dark.

With that assumption, you should monitor your system from the outside. A simple first step would be an app on your phone with notif on ping failure to your public IP, something like: https://play.google.com/store/apps/details?id=se.ping.android.hostmonitor&hl=en

If you wanna get fancier, you can arrange to regularly send REST requests to openHAB and notify when it is KO. That’s doable with tasker for sure.

This way you get a notif even if a meteor blasts your house. You wouldn’t have to worry about spoiled food in that case, though…

1 Like

I would agree that running Spotify on a phone, and then trying to control that client from OpenHAB is a bit of a hack. Obviously possible… but perhaps a lot of extra steps that will just cause issues. You should consider a SqueezeBox setup… you can easily integrate this with OpenHAB, and there is a Spotify plugin, so you can access all your local music, as well as Internet Radio, etc. Your Spotify client and server could be on the Pi, but a Pi 2 would probably be better as this is starting to be a fair amount of stuff running (there is a distro with all the SqueezeBox stuff ready to go for the Pi).

As for the notification, from the inside, I would say an older USB GSM modem plugged into the Pi would be the surest approach to get a power outage SMS notification. You’d need to look for some software for handling the incoming and outgoing SMSes, but this would mean that the Internet everywhere could be down, and your text would still go through as it is only using the mobile network. Although MUCH easier, any API service like Twilio requires the Internet to be working between you and the service provider.

This post was flagged by the community and is temporarily hidden.