BASH and events

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

BASH and events

Post by nosehook »

Hi,

I am quite unfamiliar with Bash and I have managed to make a rudi-mental script for what I want, however it doesn't always work.

What I want:
when I flick a (virtual) switch, I want the following to happen:
1) switch on a KAKA switch
2) wait for my Harmony Hub to come online (preferably via ping)
3) wait 5 seconds
4) select the right program for the Hub (TV and surround on and at right channels etc)
5) wait 5 seconds
6) Wake my HTPC

Right now I have set up a script that does step 1,4 and 6 via a curl command and the rest via sleep. However I have not managed to check for the Hub via Bash, so right now I wait 2 minutes, however, this occasionally does not work, so I'd like to send the commands when the Hub is online.
Anybody able to help me?

Cheers,

Freek
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: BASH and events

Post by Egregius »

Does the hub have a api you can call? Like json or something?
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: BASH and events

Post by nosehook »

No not that I am aware no, however Domoticz can communicate with it
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
User avatar
Egregius
Posts: 2592
Joined: Thursday 09 April 2015 12:19
Target OS: Linux
Domoticz version: v2024.7
Location: Beitem, BE
Contact:

Re: BASH and events

Post by Egregius »

In step 4 you do a curl. That should be a api.
What is the url? What is the output if you open that url in a browser?
nosehook
Posts: 49
Joined: Thursday 31 March 2016 20:49
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: BASH and events

Post by nosehook »

I don't know if it can be done with an API, therefore I use the url and therefore I want to check via a ping if the Hub is online.
IF it is doable via an API, where do I find the info?
Pi3 Domoticz | RFXcom 433E | KAKU/COCO |Harmony Hub | Samsung TV | HS100 | HS110| HUE | Tradfri | Tado| Xiaomi |sensors | scripts| Pi3 Node Red | Pi2 SDS_011 + MH-Z19B | PiAware (zero) | Pi2 breadboard with Node red and Domoticz
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest