“Sleep/bed” switch (if you charge an iOS14 device at night)

Moderator: leecollings

Post Reply
User avatar
najtram
Posts: 62
Joined: Wednesday 26 April 2017 11:50
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.9700
Location: Netherlands
Contact:

“Sleep/bed” switch (if you charge an iOS14 device at night)

Post by najtram »

If you have iOS (14!) devices and you always charge at night time this works.

Quick and dirty description:
In domoticz create dummy switch for “phone charging” and lookup the idx.

In iOS app shortcuts create an personal automation for when cable connects. In the automation create an action to get URL headers. Give url as: http://IP:PORT/json.htm?type=command&param=switchlight&idx=IDX&switchcmd=On
(replace CAPS to yours).
Uncheck “Ask before tuning”
And run and help first time and give permissions to uppopping dialogs. After this it can run automaticly.

Repeat iOS process for “cable disconnects” and use “Off” in end of url.

With an additional dummy switch and a blockly event you could filter if charging starts after your avarage bedtime. (To filter out extra charge moments at daytime).

Best to use internal ip adress to only start domoticz automation based on dummy switches when your at home. (So no automation happens when away).


Let me know what you think of it. :roll:
RFLink Gateway → 433Mhz/KAKU switches
Z-Wave → Z-Stick Gen5+
ZigBee → ConBee II
Bluetooth → Soma Smart Shades
Opentherm Gateway → Remeha iSense - Tzerra boiler
ESP8266+CC1101 → ITHO ecofan RFT
P1 cable → DSMR 2.2+ Landys +gyr E350
LAN → Enphase Envoy
krizzz
Posts: 200
Joined: Wednesday 20 November 2013 20:36
Target OS: Linux
Domoticz version:
Location: The Netherlands
Contact:

Re: “Sleep/bed” switch (if you charge an iOS14 device at night)

Post by krizzz »

What is the additional benefit of having an “iPhone is charging” device in Domoticz? I don’t get it.


Verzonden vanaf mijn iPhone met Tapatalk
User avatar
najtram
Posts: 62
Joined: Wednesday 26 April 2017 11:50
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.9700
Location: Netherlands
Contact:

Re: “Sleep/bed” switch (if you charge an iOS14 device at night)

Post by najtram »

I've seen people creating complex things to detect if a bed is occupied. (Example: https://medium.com/@qz_li/smart-bed-7de9ad55276e)
This creates the possibility to automate actions based on the assumption that when (in my case two) iPhones are charging after an avarage bedtime, we are in bed. So this could trigger actions like switching scenes, or setting up alarm.

The above description is a proof of concept of a (IMHO) simpler method than the medium post.
RFLink Gateway → 433Mhz/KAKU switches
Z-Wave → Z-Stick Gen5+
ZigBee → ConBee II
Bluetooth → Soma Smart Shades
Opentherm Gateway → Remeha iSense - Tzerra boiler
ESP8266+CC1101 → ITHO ecofan RFT
P1 cable → DSMR 2.2+ Landys +gyr E350
LAN → Enphase Envoy
User avatar
kiddigital
Posts: 438
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: “Sleep/bed” switch (if you charge an iOS14 device at night)

Post by kiddigital »

Nice idea
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
krizzz
Posts: 200
Joined: Wednesday 20 November 2013 20:36
Target OS: Linux
Domoticz version:
Location: The Netherlands
Contact:

Re: “Sleep/bed” switch (if you charge an iOS14 device at night)

Post by krizzz »

najtram wrote:I've seen people creating complex things to detect if a bed is occupied. (Example: https://medium.com/@qz_li/smart-bed-7de9ad55276e)
This creates the possibility to automate actions based on the assumption that when (in my case two) iPhones are charging after an avarage bedtime, we are in bed. So this could trigger actions like switching scenes, or setting up alarm.

The above description is a proof of concept of a (IMHO) simpler method than the medium post.
Got it!


Verzonden vanaf mijn iPhone met Tapatalk
User avatar
Treve
Posts: 107
Joined: Thursday 05 November 2015 10:37
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.11474
Location: Rotterdam, NL
Contact:

Re: “Sleep/bed” switch (if you charge an iOS14 device at night)

Post by Treve »

Thank you for this description, it works well.
when the status changes, I get a notification via Safari, can this be turned off?

Can I use the same command line with a different IDX for arrival and departure in the iOS app shortcuts?
- RFXtrx433E,
- AEON Labs ZW090 Z-Stick Gen5 EU
- Hue v2.1
- Raspberry Pi 3 Model B, Raspbian Stretch Full on USB-Stick.
- Domoticz 4.11474
Devices: KaKu, Z-Wave, Hue.

for testing:
Raspberry 4, 2GB, SSD
Domoticz 2022.1
Ikea Hub, Fyrtur curtain
User avatar
najtram
Posts: 62
Joined: Wednesday 26 April 2017 11:50
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.9700
Location: Netherlands
Contact:

Re: “Sleep/bed” switch (if you charge an iOS14 device at night)

Post by najtram »

Not sure what you mean, did you use the action called URL headers (I think) → In dutch "Haal kopteksten van URL op" (I'm sure!)
And, as said, use/help it first times. After this it's automated. (Be sure to uncheck the last option in iOS).

Leave/arrive at home isn't possible in iOS shortcuts AFAIK. Not all actions in iOS can run stand alone. This description is based on the cable connect trigger, which can run without user interaction.

There might be a workaround if you always use carplay when you leave. (But that doens't fit my usage).

Triggers can be read here: https://9to5mac.com/2020/06/23/ios-14-s ... ders-more/

PS I use the app Pilot to achieve geofencing.
RFLink Gateway → 433Mhz/KAKU switches
Z-Wave → Z-Stick Gen5+
ZigBee → ConBee II
Bluetooth → Soma Smart Shades
Opentherm Gateway → Remeha iSense - Tzerra boiler
ESP8266+CC1101 → ITHO ecofan RFT
P1 cable → DSMR 2.2+ Landys +gyr E350
LAN → Enphase Envoy
User avatar
Treve
Posts: 107
Joined: Thursday 05 November 2015 10:37
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.11474
Location: Rotterdam, NL
Contact:

Re: “Sleep/bed” switch (if you charge an iOS14 device at night)

Post by Treve »

I used (in Dutch) 'Open URLs' and turned off 'prompt to execute', Unchecked “Ask before tuning”, then allowed automatic execution at first startup.
All this works fine, but as soon as I plug in the charger, Safari get me the message,
{
"status" : "OK",
"title" : "SwitchLight"
}

Is this message normal or have I made a mistake somewhere? the switch in Domoticz has been switched from Off to On.
So technically it works
- RFXtrx433E,
- AEON Labs ZW090 Z-Stick Gen5 EU
- Hue v2.1
- Raspberry Pi 3 Model B, Raspbian Stretch Full on USB-Stick.
- Domoticz 4.11474
Devices: KaKu, Z-Wave, Hue.

for testing:
Raspberry 4, 2GB, SSD
Domoticz 2022.1
Ikea Hub, Fyrtur curtain
User avatar
najtram
Posts: 62
Joined: Wednesday 26 April 2017 11:50
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.9700
Location: Netherlands
Contact:

Re: “Sleep/bed” switch (if you charge an iOS14 device at night)

Post by najtram »

Ok, then you should use the action with the name "Haal kopteksten van URL op" instead of "Open URL's"

That should work! Let me know.
RFLink Gateway → 433Mhz/KAKU switches
Z-Wave → Z-Stick Gen5+
ZigBee → ConBee II
Bluetooth → Soma Smart Shades
Opentherm Gateway → Remeha iSense - Tzerra boiler
ESP8266+CC1101 → ITHO ecofan RFT
P1 cable → DSMR 2.2+ Landys +gyr E350
LAN → Enphase Envoy
User avatar
Treve
Posts: 107
Joined: Thursday 05 November 2015 10:37
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.11474
Location: Rotterdam, NL
Contact:

Re: “Sleep/bed” switch (if you charge an iOS14 device at night)

Post by Treve »

Yes, it works perfectly.
Thanks for your help
- RFXtrx433E,
- AEON Labs ZW090 Z-Stick Gen5 EU
- Hue v2.1
- Raspberry Pi 3 Model B, Raspbian Stretch Full on USB-Stick.
- Domoticz 4.11474
Devices: KaKu, Z-Wave, Hue.

for testing:
Raspberry 4, 2GB, SSD
Domoticz 2022.1
Ikea Hub, Fyrtur curtain
lost
Posts: 660
Joined: Thursday 10 November 2016 9:30
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: “Sleep/bed” switch (if you charge an iOS14 device at night)

Post by lost »

kiddigital wrote: Thursday 04 February 2021 10:19 Nice idea Image
Charging lithium batteries every night? Can be, if you're really confident with your smoke detectors!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest