Код: Выделить всё
;;;;;;;;;;;;;;;;;;
;Дверь_кнопка2
;;;;;;;;;;;;;;;;;;
exten => 9902,1,Ringing()
exten => 9902,2,TrySystem(curl -L 'http://localhost:8080/ipcamera/Kalitka/ipcamera.jpg' -o /export/Data/domofon/ipcamera.jpg)
;Делаем скриншот с камеры вызывной панели и сохраняем в папку /export/Data/domofon/, папку меняйте под себя, у меня эта папка просто расшарена для удобства. У меня скриншот делается через биндинг ИП-камер Опенхаба, который в том числе работает с домофонами.
exten => 9902,3,TrySystem(curl --location -g --request POST 'http://localhost:8001/api/v1/recognition/recognize?limit=2&det_prob_threshold=0.9' --header 'Content-Type: multipart/form-data' --header 'x-api-key: fe899886-9d0f-4fd0-860a-406c5b1623de' --form 'file=@/export/Data/domofon/ipcamera.jpg' -o '/export/Data/domofon/face.txt')
;Отсылаем картинку Компрефэйсу, x-api-key менять на свой на полученный из веб-интерфейса Компрефэйса, просим распознать до двух самых крупных лиц, с достоверностью 0.9, результат сохраняем в face.txt
exten => 9902,4,TrySystem(curl -X POST 'http://192.168.2.9:8080/rest/items/FaceRecognitionResult' -H 'accept: */*' -H 'Content-Type: text/plain' -d '@/export/Data/domofon/face.txt' 'http://localhost:8080/rest/items/FaceRecognitionResult')
;Запихиваем результат распознавания лиц в итем FaceRecognitionResult, дальше его можно парсить как json в правиле Опенхаба, срабатывающем при каждом изменении этого итема, например, если в результате будет subject: Misha, то послать сигнал открытия калитки.
exten => 9902,5,TrySystem(rm -f /export/Data/domofon/ipcamera.jpg /export/Data/domofon/face.txt)
;Чистим за собой.
exten => 9902,n,Wait(5)
exten => 9902,n,Hangup()
;Ложим трубку.
Код: Выделить всё
uid: ClickablePTZCamera
tags:
- video
props:
parameters:
- context: item
label: Camera image URL
name: camerajpeg
required: true
type: TEXT
- context: item
label: Camera stream URL
name: camerahls
required: false
type: TEXT
- context: item
label: Motion item
name: motionItem
required: false
type: TEXT
- context: item
label: Item for the door lock
name: lockItem
required: false
type: TEXT
- context: item
label: Item for door state
name: doorItem
required: false
type: TEXT
- context: item
description: Ipcamera MP4 history length item
label: MP4 history length
name: history
required: true
type: TEXT
timestamp: Aug 10, 2022, 8:41:38 PM
component: f7-card
config:
style:
border-radius: var(--f7-card-expandable-border-radius)
box-shadow: 5px 5px 10px 1px var(--f7-bars-bg-color)
color: var(--f7-text-color)
font-size: medium
font-weight: 500
max-height: 150px
noShadow: false
slots:
default:
- component: oh-image
config:
action: popover
actionModal: widget:Video
actionModalConfig:
camerahls: =props.camerahls
history: =props.history
doorItem: =props.doorItem
lockItem: =props.lockItem
motionItem: =props.motionItem
item: =[props.camerajpeg]
lazy: true
style:
border-radius: var(--f7-card-expandable-border-radius)
height: 150px
margin: 0px
padding: 0px
width: 100%
z-index: -2
- component: f7-row
config:
style:
position: absolute
top: 2px
width: 99%
z-index: 30
slots:
default:
- component: oh-icon
config:
icon: "=(items[props.doorItem].state === 'ON') ? 'door-closed' : 'door'"
style:
color: "=(items[props.doorItem].state === 'ON') ? 'cyan' : 'red'"
z-index: 99
visible: =props.doorItem !== undefined
width: 22
- component: oh-button
config:
action: command
actionCommand: ON
actionItem: =props.lockItem
class: card-prevent-open
iconF7: "=(items[props.lockItem].state === 'ON') ? 'lock_open' : 'lock'"
iconSize: 23
style:
color: "=(items[props.lockItem].state === 'ON') ? 'cyan' : 'var(--f7-card-header-text-color)'"
margin-left: auto
margin-right: auto
z-index: 99
visible: =props.lockItem !== undefined
- component: oh-icon
config:
icon: "=(items[props.motionItem].state === 'ON') ? 'mymotion-on' : 'mymotion-off'"
style:
z-index: 99
visible: =props.motionItem !== undefined
width: 23
Код: Выделить всё
uid: Video
tags:
- video
props:
parameters:
- context: item
label: Camera stream URL
name: camerahls
required: true
type: TEXT
- context: item
description: Ipcamera MP4 history length item
label: MP4 history length
name: history
required: true
type: TEXT
- context: item
label: Motion item
name: motionItem
required: false
type: TEXT
- context: item
label: Item for the door lock
name: lockItem
required: false
type: TEXT
- context: item
label: Item for door state
name: doorItem
required: false
type: TEXT
parameterGroups: []
timestamp: Aug 10, 2022, 11:19:10 PM
component: f7-block
config:
key: =Math.random() + vars.archive + vars.rewind
style:
margin: 0
margin-left: auto
noShadow: false
padding: 0
color: (--var-f7-text-color)
text-shadow: 1px 0px 2px black, -1px 0px 2px black, 0px 0px 2px black, 0px 0px 3px black
width: 97%
slots:
default:
- component: oh-video
config:
hideControls: false
startManually: false
item: =props.camerahls
visible: =(vars.archive !== 2)
- component: oh-video-card
config:
hideControls: false
startManually: false
url: ="http://192.168.2.9:8080/static/doorphone/Domofon" + (vars.rewind || items[props.history].state -1) + ".mp4"
type: video/mp4
visible: =(vars.archive == 2)
- component: f7-row
config:
style:
position: absolute
top: 10px
width: 99%
z-index: 30
slots:
default:
- component: oh-button
config:
action: variable
actionVariable: archive
actionVariableValue: 2
iconColor: white
iconF7: folder
iconSize: 30
visible: =(vars.archive !== 2)
tooltip: Видеоархив
- component: oh-button
config:
action: variable
actionVariable: archive
actionVariableValue: 1
iconColor: white
iconF7: videocam
iconSize: 30
visible: =(vars.archive == 2)
tooltip: Камера
- component: oh-button
config:
action: variable
actionVariable: rewind
actionVariableValue: =(vars.rewind != undefined)?(( vars.rewind > 1 )?(vars.rewind - 1):1):(items[props.history].state -2)
iconColor: white
iconF7: backward_end
iconSize: 30
visible: =(vars.archive == 2)
tooltip: Назад
- component: oh-icon
config:
icon: "=(items[props.doorItem].state === 'ON') ? 'door-closed' : 'door'"
style:
color: "=(items[props.doorItem].state === 'ON') ? 'cyan' : 'red'"
z-index: 99
visible: =((props.doorItem !== undefined) && (vars.archive !== 2))
width: 30
- component: oh-button
config:
action: command
actionCommand: ON
actionItem: =props.lockItem
class: card-prevent-open
iconF7: "=(items[props.lockItem].state === 'ON') ? 'lock_open' : 'lock'"
iconSize: 30
style:
color: "=(items[props.lockItem].state === 'ON') ? 'white' : 'red'"
margin-left: auto
margin-right: auto
z-index: 99
visible: =((props.lockItem !== undefined) && (vars.archive !== 2))
- component: oh-icon
config:
icon: "=(items[props.motionItem].state === 'ON') ? 'mymotion-on' : 'mymotion-off'"
style:
z-index: 99
visible: =((props.motionItem !== undefined) && (vars.archive !== 2))
width: 30
- component: oh-button
config:
action: variable
actionVariable: rewind
actionVariableValue: =( vars.rewind < items[props.history].state - 1)?(vars.rewind + 1):(items[props.history].state - 1)
iconColor: white
iconF7: forward_end
iconSize: 30
visible: =(vars.archive == 2)
tooltip: Вперёд
- component: oh-button
config:
iconColor: white
iconF7: clear
iconSize: 30
popoverClose: .popover.modal-in
style:
z-index: 99
tooltip: Закрыть