|
Here's part of a sample sequence:
1) Smarthome gets a notification of a vehicle detected in the driveway
2) sends a request to get an image from the driveway camera
3) gets the image, sends it off for storage and analysis
4) sends it to an image recognition service which returns a description(make/model/color + other info) as JSON
5) receives analysis, matches it to known vehicles and announces the results The send_display_vehicle_id(Id) in the end actually does a lot, it queries redis for previously announced display type devices, then looks up the capabilities (bit depth, resolution) of each device and formats accordingly then sends the display request for each. Also send_android_notification sends the request to some Java code that initiates a push message to my phone and watch. None of this is rocket science in terms of Prolog message(MQTTPathAsList, MessageBody) is my general predicate for handling an incoming MQTT message once I've subscribed to it and it's convenient to deal with a MQTT topic path as a list. message(['Smarthome','Notify', 'vehicle','motion'],_):-
log('brain saw vehicle motion'),
get_short_timestamp(S),
atomic_list_concat([S, ' Vehicle Motion'], NotificationMessage),
send_android_notification('Smarthome', NotificationMessage),
request_image('alibi4'). request_image(Camera) :-
publish(['Smarthome', 'Video', Camera, 'brain', 'request']). message(['Smarthome','Video', _ ,'brain','response'],Image):-
store_image(Image, 'brain'),
analyze_image(Image, 'brain'). analyze_image(Image, Id) :-
publish(['Smarthome', 'Sighthound', 'analyze', Id], Image). message(['Smarthome','Vehicle', 'Sighthound'],VehicleJson):-
vehicle_id(VehicleJson, Id),
get_short_timestamp(S),
atomic_list_concat([S, ' brain saw vehicle: ', Id], NotificationMessage),
send_android_notification('vehicle', NotificationMessage),
send_display_vehicle_id(Id),
atom_concat(Id, VehicleJson, Description),
atom_concat('brain saw vehicle: ', Description, Message),
log(Message). |