Example #1
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Выключает выключатели света через zwave
# Аргументы:
# <script_name> sensor_id
# sensor_id - ID сенсора, вызвавшего запуск
#
import sys
import RPi.GPIO as GPIO
import string
import subprocess
sys.path.append('/home/scripts/libs')
from mySensors import mySensors

sensor_id = int(sys.argv[1])

mySensors = mySensors()
sensor = mySensors.getSensor(sensor_id)
zwaveID = str(sensor['sensor'])

if zwaveID:
    subprocess.Popen(['/home/scripts/zwave/zwave-switch.py', zwaveID, '0'])

#!/home/scripts/venv/python3/bin/python3
# -*- coding: utf-8 -*-
# Выключает выключатели света через zwave
# Эмуляция проходного выключателя в коридоре
# Старая версия (zwave - zwave) в файле hall-light-loop-switch.py
#
import sys,os,time
import RPi.GPIO as GPIO
import string
import subprocess
import zc.lockfile
sys.path.append('/home/scripts/libs')
from mySensors import mySensors
from myRunLock import myRunLock

sensor_id = int(sys.argv[1]);

lock = myRunLock(str(sensor_id))

mySensors = mySensors()
lightOn = mySensors.getSensor(65)['state'] == 'ON';
if (lightOn):
    subprocess.Popen(['/home/scripts/actions/espnow-switch.py', "65", 'POFF'])
else:
    subprocess.Popen(['/home/scripts/actions/espnow-switch.py', "65", 'PON'])
lock.release()
Example #3
0
#!/home/scripts/venv/python3/bin/python3
# -*- coding: utf-8 -*-

import sys
import RPi.GPIO as GPIO
import string

sys.path.append('/home/scripts/libs')
from mySensors import mySensors
from myFCM import myFCM

sensor_id = 98

mySensors = mySensors()

state = mySensors.getSensor(sensor_id)
mySensors.saveSensorState(sensor_id, 'POFF', True)

fcm = myFCM()
data = {
    'message': {
        'message': "Kitchen oven is switched OFF",
        'text': "Kitchen oven is switched OFF",
        'cmd': 'showAlert',
        'from': 'raspberry',
    }
}
fcm.send('mirageLG,taniaLG,group=chrome', data)
#fcm.send('mirageLG,taniaLG',data);