I need some Ideas on how to realise my Idea of a LED Timer based on my current Location

Hello there,

I am quite new to openhab and everything considering IoT, Smart Home and so on, but everyone started from scratch once, right?

I have an Idea for a Project but I am unsure where to Start and I hope maybe to get some hints or some tipps for the right direction. My Idea is to create a LED Bar that indicates my Distance from home.

My Kids always asks my Wife “When does Daddy coming home?” and often she can’t give them an satisfying answer. So I made up an Idea on how to visualize them when I am home. My Idea is that I start a Trigger when I leave from work (Leaving a Zone or by pushing a Button) and at home a LED Bar Lights Up in Red. The LED Bar acts as a visual countdown and turns Green LED by LED as I get closer to home.

Visualizing a Timer is probably not that difficult. But I need a routine that takes my current Location, calculates the estimated time for me to reach home and transfers it into a device that starts a countdown based on that time and changes the Red LEDs Green as time passes.

The Strip shouldn’t light up all the time. When I start it should light Up to indicate that I am on my way. After a minute it should turn off and maybe there can be a Button on it which a Person could press to see the current status. After a Minute the Lights should turn off again.

As I own an iPhone, I was thinking about using a Shortcut or the app Scriptable to take my current location, pass it to google maps to calculate the time needed to get home. But I am stuck on how to get these data to a device (Raspberry Pi maybe or an ESP32).

I am not sure how this will work, as I have not tried something like it.

The GPS tracker binding will be able to track you through zones, then tie this into some ws2812b led’s running on a d1 mini, using tasmota and Mqtt

Should keep you busy for a while.

1 Like

I have something similar that uses zoning (distance from home) using the iCloud binding. When I move through zones it announces on my Amazon echos different things (1 mile away for my other half to put the kettle on :stuck_out_tongue_closed_eyes:). I’ll send you the rule tomorrow when back in front of the pc so you can see and get some ideas.
You’ll just need to get the distance (from the binding) when at work, shops etc or can use co-ordinates

Also discussed here…

1 Like

Here you go: (old version)

rule away when Item DavidHome changed or Item JodieHome changed then
	if (DavidHome.state == OFF && JodieHome.state == OFF) {

rule "Coordinates" when System started then
Home.postUpdate(new PointType(new DecimalType(51.557450),new DecimalType(0.59563)))
DavidWork.postUpdate(new PointType(new DecimalType(51.588773),new DecimalType(0.56469728)))
JodieWork.postUpdate(new PointType(new DecimalType(51.5572451553073),new DecimalType(0.5954955899693404)))

rule "David Location" 
when Item iPhoneDavidLocation changed 
    //logInfo("David Location","Updated")
if (DavidRegion.state == NULL) {
DavidDirection.postUpdate("Stationary") }
else {
val PointType DavidLocation = iPhoneDavidLocation.state as PointType
val Number distance = DavidLocation.distanceFrom(Home.state as PointType).intValue()
var Number Region
var String Direction

if (distance > -1 ) {Region = 1}
if (distance > 49 ) {Region = 2}
if (distance > 99 ) {Region = 3}
if (distance > 499 ) {Region = 4}
if (distance > 999 ) {Region = 5}
if (distance > 1999 ) {Region = 6}
if (distance > 3999 ) {Region = 7}

if (Region < DavidRegion.state) {Direction = "In"} 
else if (Region > DavidRegion.state) {Direction = "Out"}
else {Direction = "Stationary"}

if (Region == 1) {DavidHome.postUpdate(ON) HomeMode.postUpdate(ON)}
else {DavidHome.postUpdate(OFF)}

if (Region < 5 && DavidRegion.state > 4 && JodieHome.state == ON) {
    KitchenAlexaTTS.sendCommand('Put the kettle on dave is nearly home')}

if (Region > 1 && JodieHome.state == OFF) {HomeMode.postUpdate(OFF)}


rule "Jodie Location" 
when Item iPhoneJodieLocation changed 
    //logInfo("Jodie Location","Updated")
if (JodieRegion.state == NULL) {
JodieDirection.postUpdate("Stationary") }
else {
val PointType JodieLocation = iPhoneJodieLocation.state as PointType
val Number distance = JodieLocation.distanceFrom(Home.state as PointType).intValue()
var Number Region
var String Direction

if (distance > -1 ) {Region = 1}
if (distance > 49 ) {Region = 2}
if (distance > 99 ) {Region = 3}
if (distance > 499 ) {Region = 4}
if (distance > 999 ) {Region = 5}
if (distance > 1999 ) {Region = 6}
if (distance > 3999 ) {Region = 7}

if (Region < JodieRegion.state) {Direction = "In"} 
else if (Region > JodieRegion.state) {Direction = "Out"}
else {Direction = "Stationary"}

if (Region == 1) {JodieHome.postUpdate(ON) HomeMode.postUpdate(ON)}
else {JodieHome.postUpdate(OFF)}

if (Region < 5 && JodieRegion.state > 4 && DavidHome.state == ON) {
    KitchenAlexaTTS.sendCommand('Put the kettle on jodie is nearly home')}

if (Region > 1 && DavidHome.state == OFF) {HomeMode.postUpdate(OFF)}

1 Like

Thanks. I had no idea that OpenHAB had a iCloud Binding. I had the Idea using a Shortcut to SSH into the Pi and execute a Script with a Countdown. As Hardware I thought of a Pi Zero WiFi with some WS2812b. So I can use one Plug to power the Pi and the LED Strip.

I would concur with @Adrian_Hills suggestion and use an esp8266 based board (such as the D1 Mini, or a NodeMCU) - these are WiFi enabled and much cheaper than a Pi Zero (even if a Zero doesn’t actually cost that much either!).

Then just flash the WLED project onto it, and communicate with openHAB either via the binding, or through MQTT.

For the WS2812b, just check the number of LEDs that you plan to use and make sure the power supply is rated high enough to power both the board and the strip. I think each LED can consume up to 60mA at full bright white - they’re hungry little beasts! You may want to consider powering the strip directly from the power supply, rather than through the board (which I think is what you’re suggesting already, but just making sure!)

Use wled but the binding is probably not going to help much. You will need to use the http binding and send a json packet from a openhab rule. See here

Interesting - I wrongly assumed the binding handled segments too! Apologies!

I notice that the HTTP API can also be used to control segments, which would therefore also work over MQTT on the [mqttDeviceTopic]/api topic. However, WLED suggests using the JSON API instead of the HTTP API, so it does indeed look like the HTTP binding + JSON packets from rules is the way to go here!

It does handle segments to a degree, however I dont think the OP really wants segment control but much finer PIXEL level control. A child will get bored with a short string that barely changes, so a long string that keeps changing will be of more interest as lights keep changing and I dont know how many segments you are limited in creating on a single string. It could be done that way if you don’t hit a limit.
Also it may be easier to use the whole string via the binding without segments and then switch into using pixel level control just for the 1 use case. Not something that I have played with as I only have a single string on my Christmas tree.

Another way would be to use DMX (openhab has a binding for this) or one of the many other protocols the WLED project also supports.

There is no reason why you cant use multiple methods to talk to the lights at the same time.

That actually is not an issue as the WLED firmware can software limit the current for you. I use 200 leds off a common 2 amp power supply. You find this in the led setup page and the leds are plenty bright enough as the brightness VS current is not linear.

Right, I was assuming that each segment would have a single pixel. We don’t know how many pixels OP wants and I also

True, I also use this feature. Maybe I should rephrase to say that if you want full brightness, check the power requirements for both the power supply and what the board can provide!

Just be aware that the iCloud binding does suffer from a yearly certificate update so may be a couple of days a year it doesn’t work whilst the cert is updated in the binding. And also that from memory it only updates every 5 minutes I think (minimum). There are others you can use such as OwnTracks if you want another app

I have a Pi Zero W to spare so that isn’t really a expense to consider. But I will try to realise the Project with the Pi and with an ESP8266 (Wemos D1 Mini & WLED). I got myself a 5v 3A Power Supply which I was thinking of splicing up to power the Device and the LED Strip both directly attached to the PSU. The LED Strip will be a 1m 30LED WS2812b Strip. So, even with 60mA per LED I have enough to power the Strip and the Pi and even got some mA to spare.

I like Daves Idea with the Zones, but sometims I have to drive to a customer who lives close to my Home or I have to drive my traditional route home and beyond that to reach another customer. This would trigger the Strip unwanted and thinking about limiting everything with current time could be a problem, too as I sometimes work only Half-Days.

Right now, the easiest approach I see is using an iOS Shortcut to connect to a Device through SSH and executing a Script. Maybe I could SSH into my openhabian and trigger a rule (When User XYZ logs in with SSH then…)?

I could also add an Aqara Button to the Strip which, when pressed, takes my location from the iCloud binding, passes them to the Google API which then calculates the time I need to reach home and uses the result as the duration for the timer. But then I need a Start and a Check button or it would reset every time the button is pressed.

I think about recording my Process and making a Youtube Video about it. I have no Idea if people are interessted at entry Level projects from a bare amateur who has no follower (Seeing me Yelling at Stuff until it works and despairing at the simplest problems might not be as fun as it sounds).

Could you implement something like my rule above but have an override switch, effectively only running the rule if the switch is on/off. That way if your going to see clients etc then you can flick the switch in the iOS openhab app and it then won’t update the led.

You could even add HomeKit to the switch with the HomeKit binding so you can just use Siri on your phone (provided you have HomeKit setup) or get an Amazon echo auto in the car and add Alexa support.

So many possibilities and ways :wink:

I’ve also just seen that the echo auto has had location services enabled by Amazon. It’s not implemented in the binding at present or the pre-release as far as I can tell but I’ve asked the question as I too would be interested in this. It’s predominately designed for customers to have location tracking by the looks of it

I had a simple, yet effective Idea. I made a virtual Switch in OpenHAB an published it with Homebridge to my iPhone. As I also own an Apple TV, this enables me to trigger the switch even when I am away. I make a rule that when the Switch is turned on, my location is taken from the iCloud Binding and passed to the Google API (No Idea how this works but that is the fun part, right) to calculate my estimated time to get home.

Basically that what you just said.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.