view service/reasoning/rules.n3 @ 754:3175fd4d0418

use local FuXi checkout of https://github.com/drewp/FuXi (and some other dep updates) Ignore-this: 7d32ca4fcf5f3064b7615c279eb10ac1
author drewp@bigasterisk.com
date Thu, 13 Feb 2020 22:58:56 -0800
parents 098ea942aefe
children 3c18ec6cb6ef
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 :motion . } => {
  :storageCeilingLedCross :brightness 1.0 .
  :storageCeilingLedLong :brightness 1.0 .
} .

{ 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.0 .
} .

@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 .
  :livingRoomLamp3 :brightness 1.0 .
} .
{ :bookSwitch :buttonState :press . :livingRoomLamp1 :brightness 1.0 . } => {
  :livingRoomLamp1 :brightness 0.0 .
  :livingRoomLamp2 :brightness 0.0 .
  :livingRoomLamp3 :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 .
# } .

{ :frontBedPostSwitch1 :buttonState :press . } => { :loftDeskStrip :x 99.0
. } .
{ :frontBedPostSwitch2 :buttonState :press . } => { :loftDeskStrip :x 84.0
. } .
{ :frontBedPostSwitch3 :buttonState :press . } => { :loftDeskStrip :x 53.0
. } .
{ :frontBedPostSwitch4 :buttonState :press . } => { :loftDeskStrip :x 15.0
. } .
{ :frontBedPostSwitch5 :buttonState :press . } => { :loftDeskStrip :x 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 :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 .
  :frontWindow :line2 "Unlocked" .
}.

{
  :cardReader :currentRead ?card .  # mailslot reader
} => {
  :frontWindow :line1 "Card found" .
}.

{
:cardReader :currentRead ?card .  # mailslot reader
#  :frontDoorWindowRfid :reading ?card .  # glass reader
#  ?card :cardText ?text . # id only
  ?card :owner ?agent .
} => {
 # :frontWindow :line2 "Access granted" .
  :frontDoorLock :putState :unlocked .
  :frontDoorLock :putAgent ?agent .
} .

{
  :frontDoorOpenSwitch :buttonState :pressed .
} => {
  :frontWindow :line3 "Open" .
} .