Rozdíly

Zde můžete vidět rozdíly mezi vybranou verzí a aktuální verzí dané stránky.

Odkaz na výstup diff

Obě strany předchozí revize Předchozí verze
Následující verze
Předchozí verze
Následující verze Obě strany příští revize
diy:bigclown-pir [15.05.2019 16:58]
vm
diy:bigclown-pir [16.05.2019 22:23]
vm
Řádek 1: Řádek 1:
-====== PIR controlled water Fountain ====== 
- 
-This project uses BigClown'​s PIR module to control the power of a cat water fountain. 
- 
-{{ :​diy:​cat.jpg?​nolink&​800 |}} 
- 
-===== What is used ===== 
-**Parts:** 
-  - BigClown 
-    - Motion Detector Kit (https://​shop.bigclown.com/​motion-detector-kit/​) 
-    - Radio Dongle (https://​shop.bigclown.com/​radio-dongle/​) 
-  - Smart Plug tp-link HS110 (https://​www.tp-link.com/​en/​home-networking/​smart-plug/​hs110/​) 
-  - Raspberry Pi 1 Model B Rev 2 
- 
-**Tools:** 
-  - [[https://​www.home-assistant.io/​|Home Assistant]] 
-  - MQTT Broker (in my case [[https://​mosquitto.org/​|Mosquitto]] 
- 
-===== How it works ===== 
-When PIR sensor detects movement it sends message to Radio Dongle plugged to the Raspberry Pi which sends the message to the MQTT server. On the other side MQTT message is processed by the Home Assistant which then using the automation triggers smart plug and starts configured countdown. 
- 
-===== Radio Dongle ===== 
-In my deployment, I wanted to reuse old Raspberry Pi 1 Model B Rev 2 for the BigClown Radio Dongle, which was quite challenging as the standard installation was not supported on this particular old version of Pi. So plan B was needed, install it manually :-)  
- 
-<code bash> 
-# Install Python 
-apt install python3 python3-pip python3-setuptools 
-pip3 install --upgrade pip 
- 
-# Install BigClown tooling 
-pip3 install --upgrade bcf bcg bch 
-</​code>​ 
-When we have needed tools ready, let's create udev rule for the dongle: 
-<code bash> 
-echo '​SUBSYSTEMS=="​usb",​ ACTION=="​add",​ KERNEL=="​ttyUSB*",​ ATTRS{idVendor}=="​0403",​ ATTRS{idProduct}=="​6015",​ ATTRS{serial}=="​bc-usb-dongle*",​ SYMLINK+="​bcUD%n",​ TAG+="​systemd",​ ENV{SYSTEMD_ALIAS}="/​dev/​bcUD%n"' ​ | sudo tee --append /​etc/​udev/​rules.d/​58-bigclown-usb-dongle.rules 
-</​code>​ 
- 
-After the RPi restart Radio Dongle should be properly detected now: 
-<​code>​ 
-# ls /dev/bc* 
-/dev/bcUD0 
-</​code>​ 
- 
-Now we can start gateway and start submitting the MQTT messages to the broker: 
-  /​usr/​local/​bin/​bcg --device /dev/bcUD0 --mqtt-host 10.10.10.10 
- 
-===== Motion Detector ===== 
-My Motion Detector kit came with the default firmware already loaded inside and by default, the module sends updates every time the motion is detected, but no more often than 1 minute. This is fine for my intended use, but if you would like to adjust the threshold, default firmware is available on Github at repository https://​github.com/​bigclownlabs/​bcf-radio-motion-detector and in file ''​app/​application.c''​ value of ''​PIR_PUB_MIN_INTEVAL''​ needs to be adjusted accordingly. Firmware flashing process if thoroughly described in the [[https://​developers.bigclown.com/​hardware/​core-module-r1-and-r2-comparison|documentation]]. 
- 
-===== Smart Plug ===== 
-I've chosen the tp-link HS110 as it can be remotely controlled via Home Assistant without any cloud account needed but anything can be used to control the power. Other option would be to use BigClown'​s Relay Module (https://​shop.bigclown.com/​relay-module/​) and directly control the power of the water fountain, but I prefer the separate power control so I can move PIR sensor in the room freely, typically in the corridor, so the water would start flowing before the cat gets near the fountain :-) 
- 
-===== Home Assistant ===== 
-This is the excerpt of the configuration to support this scenario: 
- 
-<file ~/​.homeassistant/​configuration.yaml>​ 
-mqtt: 
-  broker: 10.10.10.10 
-  port: 1883 
- 
-switch: 
-  - platform: tplink 
-    host: 10.10.10.11 
-    name: "Water Fountain"​ 
- 
-sensor: 
-  - platform: mqtt 
-    state_topic:​ '​node/​kit-motion-detector:​0/​pir/​-/​event-count'​ 
-    name: '​Counter'​ 
-    icon: mdi:​smoke-detector 
-  - platform: mqtt 
-    state_topic:​ '​node/​kit-motion-detector:​0/​battery/​-/​voltage'​ 
-    name: '​Voltage'​ 
-    unit_of_measurement:​ '​V'​ 
- 
-input_number:​ 
-  slider_water_fountain:​ 
-    name: Timeout after PIR 
-    initial: 15 
-    min: 1 
-    max: 60 
-    step: 5 
-    unit_of_measurement:​ min 
- 
-automation: 
-  - alias: Start Water Fountain by PIR 
-    trigger: 
-      platform: state 
-      entity_id: sensor.counter 
-    action: 
-      service: switch.turn_on 
-      entity_id: switch.water_fountain 
-  - alias: Vypnutí fontány po pohybu 
-    trigger: 
-      platform: state 
-      entity_id: sensor.counter 
-    condition: 
-      condition: and 
-      conditions: 
-        - condition: state 
-          entity_id: switch.water_fountain 
-          state: '​off'​ 
-    action: 
-      service: homeassistant.turn_on 
-      entity_id: script.timed_water_fountain 
- 
-script: 
-  timed_water_fountain:​ 
-    alias: "Set water fountain timer" 
-    sequence: 
-      # Cancel ev. old timers 
-      - service: script.turn_off 
-        data: 
-           ​entity_id:​ script.timer_off_water_fountain 
-      # Set new timer 
-      - service: script.turn_on 
-        data: 
-          entity_id: script.timer_off_water_fountain 
-  timer_off_water_fountain:​ 
-    alias: "Turn off water fountain"​ 
-    sequence: 
-      - delay: '00:{{ states.input_number.slider_water_fountain.state | int }}:00' 
-      - service: homeassistant.turn_off 
-        entity_id: switch.water_fountain 
- 
-group: 
-  bcpir: 
-    name: 'PIR Sensor'​ 
-    icon: mdi:​smoke-detector 
-    entities: 
-      - sensor.voltage 
-      - sensor.counter 
- 
-  fountain: 
-    name: 'Water fountain'​ 
-    entities: 
-      - switch.water_fountain 
-      - input_number.slider_water_fountain 
-      - automation.start_water_fountain_by_pir 
- 
-</​code>​ 
  
diy/bigclown-pir.txt · Poslední úprava: 16.05.2019 22:32 autor: vm