view service/reasoning/rules.n3 @ 1288:f4ce7989d25c

mockup of thermostat rules Ignore-this: 61a460ac3bdcbc0c4c6de2a2afcc6d5c darcs-hash:66578b12e414cfaf1c1bc1b93523e90d5dd1be0d
author drewp <drewp@bigasterisk.com>
date Sun, 21 Apr 2019 00:06:12 -0700
parents 5f522c2d18bf
children c7cdde15e8f0
line wrap: on
line source

# rules only! statements in this file will not be considered in the graph

@prefix : <http://projects.bigasterisk.com/room/>.
@prefix bigast: <http://bigasterisk.com/>.
@prefix dev: <http://projects.bigasterisk.com/device/>.
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix env: <http://projects.bigasterisk.com/device/environment>.
@prefix math: <http://www.w3.org/2000/10/swap/math#> .

@prefix star: <http://bigasterisk.com/host/star/> .
@prefix bang: <http://bigasterisk.com/host/bang/> .
@prefix dash: <http://bigasterisk.com/host/dash/> .
@prefix slash: <http://bigasterisk.com/host/slash/> .

@prefix sensor: <http://bigasterisk.com/homeauto/sensor/> .

{ ?d :deviceName "drew-phone"; :connected bigast:wifiAccessPoints . } => { :auth :near :home } .
{ ?d :deviceName "Kelsis-iPhone"; :connected bigast:wifiAccessPoints . } => { :auth :near :home } .

{ env: :localHour 8 } => { env: :localHour :awakeTime } .
{ env: :localHour 9 } => { env: :localHour :awakeTime } .
{ env: :localHour 10 } => { env: :localHour :awakeTime } .
{ env: :localHour 11 } => { env: :localHour :awakeTime } .
{ env: :localHour 12 } => { env: :localHour :awakeTime } .
{ env: :localHour 13 } => { env: :localHour :awakeTime } .
{ env: :localHour 14 } => { env: :localHour :awakeTime } .
{ env: :localHour 15 } => { env: :localHour :awakeTime } .
{ env: :localHour 16 } => { env: :localHour :awakeTime } .
{ env: :localHour 17 } => { env: :localHour :awakeTime } .
{ env: :localHour 18 } => { env: :localHour :awakeTime } .
{ env: :localHour 19 } => { env: :localHour :awakeTime } .
{ env: :localHour 20 } => { env: :localHour :awakeTime } .
{ env: :localHour 21 } => { env: :localHour :awakeTime } .
{ env: :localHour 22 } => { env: :localHour :awakeTime } .
{ env: :localHour 23 } => { env: :localHour :awakeTime } .

#{
#  # this won't update right, currently, since I don't let the exact
#  # idle time into the rules recalculator. This threshold should be
#  # applied upstream.
# 
#  dash:xidle :idleTimeMinutes ?idle .
#  # broken with new  fuxi- needs review:    ?idle math:lessThan 30 .
#} => {
#  :drew :at :desk .
#  # the plan here is that as soon as we can show that I'm not at my
#  # desk (cell phone wifi, asleep, etc), power the screen off
#} .
#
#@prefix shuttle: <http://bigasterisk.com/room/livingRoom/shuttlepro/> .
#@prefix mpd: <http://bigasterisk.com/host/slash/mpd> .
#
#{ ?button :state :press . ?button :playsMusic ?song } => { mpd: :startMusic ?song } .
## the rest of this modeling is still a mess. Handled completely by special case in reasoning.py
#{ shuttle:button12 :state :press         } => { mpd: :playState :pause } .
#{ shuttle:dial :change :clockwise        } => { mpd: :audioState :volumeStepUp } .
#{ shuttle:dial :change :counterclockwise } => { mpd: :audioState :volumeStepDown } .
#


#{ sensor:motionStorage :seesRecently :noMotion . } => {
#  :storageCeilingLedCross :brightness 0 .
#  :storageCeilingLedLong :brightness 0 .
#} .

{ sensor:motionStorage :seesRecently :motion . } => {
  :storageCeilingLedCross :brightness 1 .
  :storageCeilingLedLong :brightness 1 .
} .

#{ sensor:motionStorage :sees :motionStart . } => {
#  :storageCeilingLedCross :brightness 1 .
#  :storageCeilingLedLong :brightness 1 .
#} .

{ sensor:bedGreenButton :buttonState :press } => {
  :headboardWhite :brightness 0.0 .
  :anim1 :position :end .
} .

{ sensor:bedRedButton :buttonState :press . :headboardWhite :brightness 0.0 . } => {
  :headboardWhite :brightness 0.2 . 
} .

{ sensor:bedRedButton :buttonState :press . :headboardWhite :brightness 0.2 . } => {
  :headboardWhite :brightness 1 .
} .

@prefix sensor:   <http://bigasterisk.com/homeauto/sensor/> .
{ sensor:buttonAriBed :buttonState :press } => {
  :starTrekLight :brightness 0.0 .
} .

{ sensor:motionChanging :seesRecently30 :noMotion } => {
  :changingWhite :brightness 0.0 .
  } .

{ sensor:motionChanging :seesRecently30 :motion } => {
  :changingWhite :brightness 0.3 .
} .

{ sensor:motionChanging :sees :motionStart90 . dev:calendar :twilight :daytime .} => {
  :changingCam :grab <http://bang:9057/changing-day.jpg> .
  } .

{ sensor:motionChanging :sees :motionStart90 . dev:calendar :twilight :withinTwilight .} => {
  :changingCam :grab <http://bang:9057/changing-night.jpg> .
  } .

{ :bookSwitch :buttonState :press . :livingRoomLamp1 :brightness 0.0 . } => {
  :livingRoomLamp1 :brightness 1.0 .
  :livingRoomLamp2 :brightness 1.0 .
} .
{ :bookSwitch :buttonState :press . :livingRoomLamp1 :brightness 1.0 . } => {
  :livingRoomLamp1 :brightness 0.0 .
  :livingRoomLamp2 :brightness 0.0 .
} .

{ :frontBedPostSwitch1 :buttonState :press . :starTrekLight :brightness 0.0 . } => {
  :starTrekLight :brightness 1.0 .
} .
{ :frontBedPostSwitch1 :buttonState :press . :starTrekLight :brightness 1.0 . } => {
  :starTrekLight :brightness 0.0 .
} .


#{  :change :down . } => { star:slideshow :postAction <http://brace:9049/effects/beep1> . } .
#{ sensor:kitchenCounterButton1 :buttonState :press . } => {
#  bang: :postAction <http://10.2.0.62/rpc/motor> .
#} .

{ sensor:kitchenCounterButton1 :buttonState :press . :kitchenLight :brightness 0.0 . } => {
  :kitchenLight :brightness 1.0 .
  :kitchenCounterLight :brightness 0.5 .
# and skylight rgb/rgb/set '200,255,200'
} .
{ sensor:kitchenCounterButton1 :buttonState :press . :kitchenLight :brightness 1.0 . } => {
  :kitchenLight :brightness 0.0 .
  :kitchenCounterLight :brightness 0.0 .
} .



{ <http://bigasterisk.com/homeauto/sensor/motionGarageDoorInside> :seesRecently :noMotion . } => {
  :garageOverhead :brightness 0.0.
} .

{ <http://bigasterisk.com/homeauto/sensor/motionGarageDoorInside> :seesRecently :motion . } => {
  :garageOverhead :brightness 1.0 .
} .

{ sensor:motionBed :sees :motion . } => { :anim1 :playback :start . } .


{ sensor:motionFrontdoorInside :seesRecently30 :motion } => {
  <http://bigasterisk.com/host/frontdoor/monitor> :powerState :on .
} .



{ <http://projects.bigasterisk.com/room/remoteButton/KEY_POWER> :state :press } => {
#star:slideshow :postAction <http://dash:9049/effects/question> .
bang: :postAction <http://10.2.0.62/rpc/motor> .
} .

{ <http://bigasterisk.com/homeauto/sensor/tempHumidKitchen> :temperatureF ?t .
  <http://bigasterisk.com/homeauto/thermostatSetTemp> :temperatureF ?setTemp .
  ?t math:lessThan ?setTemp .
} =>  {
  :fakeHeater :state :on .
} .

{ :frontDoorLockRequest :state :unlocked .
} => {
  :frontDoorLock :putState :unlocked .
  :frontDoorLock :putAgent :someStateRequest .
} .

{:frontDoorLock :state :locked .} => {:frontDoorOled :state :locked .}.
{:frontDoorLock :state :unlocked .} => {:frontDoorOled :state :unlockNews .}.

{
  :frontDoorWindowRfid :reading ?card .
  ?card :cardText ?text .
  ?card :owner ?agent .
} => {
  :frontDoorLock :putState :unlocked .
  :frontDoorLock :putAgent ?agent .
} .