Skip to content

Commit

Permalink
Merge 476ba5b into ccb8c48
Browse files Browse the repository at this point in the history
  • Loading branch information
HazardDede committed Feb 29, 2020
2 parents ccb8c48 + 476ba5b commit 483c405
Show file tree
Hide file tree
Showing 13 changed files with 308 additions and 24 deletions.
7 changes: 7 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env bash

pip install -r requirements.txt

echo Python Version ${TRAVIS_PYTHON_VERSION}

if [ "${TRAVIS_PYTHON_VERSION}" != '3.5' ]; then
pip install -e .[fritz]
fi

if [ "${TRAVIS_EVENT_TYPE:-none}" == 'cron' ]; then
pip install -e .[faceR]
fi
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ COPY README.md setup.py ./

RUN pip3 install \
--no-cache-dir \
.[dropbox,fitbit,fswatcher,ftp,gmail,http-server,miflora,pushbullet]
.[dropbox,fitbit,fritz,fswatcher,ftp,gmail,http-server,miflora,pushbullet]

COPY . .

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arm32v7
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ COPY README.md setup.py requirements.dev ./
RUN pip3 install \
--no-cache-dir \
--extra-index-url https://www.piwheels.hostedpi.com/simple \
.[dht,dropbox,fitbit,fswatcher,ftp,gmail,gpio,http-server,miflora,pushbullet]
.[dht,dropbox,fitbit,fritz,fswatcher,ftp,gmail,gpio,http-server,miflora,pushbullet]

COPY . .

Expand Down
86 changes: 64 additions & 22 deletions docs/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
1.11\. [pnp.plugins.pull.monitor.Stats](#pnp.plugins.pull.monitor.stats)
1.12\. [pnp.plugins.pull.mqtt.Subscribe](#pnp.plugins.pull.mqtt.subscribe)
1.13\. [pnp.plugins.pull.net.PortProbe](#pnp.plugins.pull.net.portprobe)
1.14\. [pnp.plugins.pull.sensor.DHT](#pnp.plugins.pull.sensor.dht)
1.15\. [pnp.plugins.pull.sensor.MiFlora](#pnp.plugins.pull.sensor.miflora)
1.16\. [pnp.plugins.pull.sensor.OpenWeather](#pnp.plugins.pull.sensor.openweather)
1.17\. [pnp.plugins.pull.sensor.Sound](#pnp.plugins.pull.sensor.sound)
1.18\. [pnp.plugins.pull.simple.Count](#pnp.plugins.pull.simple.count)
1.19\. [pnp.plugins.pull.simple.Cron](#pnp.plugins.pull.simple.cron)
1.20\. [pnp.plugins.pull.simple.Repeat](#pnp.plugins.pull.simple.repeat)
1.21\. [pnp.plugins.pull.traffic.DeutscheBahn](#pnp.plugins.pull.traffic.deutschebahn)
1.22\. [pnp.plugins.pull.trigger.Web](#pnp.plugins.pull.trigger.web)
1.23\. [pnp.plugins.pull.zway.ZwayPoll](#pnp.plugins.pull.zway.zwaypoll)
1.24\. [pnp.plugins.pull.zway.ZwayReceiver](#pnp.plugins.pull.zway.zwayreceiver)
1.14\. [pnp.plugins.pull.net.PortProbe](#pnp.plugins.pull.net.portprobe-1)
1.15\. [pnp.plugins.pull.sensor.DHT](#pnp.plugins.pull.sensor.dht)
1.16\. [pnp.plugins.pull.sensor.MiFlora](#pnp.plugins.pull.sensor.miflora)
1.17\. [pnp.plugins.pull.sensor.OpenWeather](#pnp.plugins.pull.sensor.openweather)
1.18\. [pnp.plugins.pull.sensor.Sound](#pnp.plugins.pull.sensor.sound)
1.19\. [pnp.plugins.pull.simple.Count](#pnp.plugins.pull.simple.count)
1.20\. [pnp.plugins.pull.simple.Cron](#pnp.plugins.pull.simple.cron)
1.21\. [pnp.plugins.pull.simple.Repeat](#pnp.plugins.pull.simple.repeat)
1.22\. [pnp.plugins.pull.traffic.DeutscheBahn](#pnp.plugins.pull.traffic.deutschebahn)
1.23\. [pnp.plugins.pull.trigger.Web](#pnp.plugins.pull.trigger.web)
1.24\. [pnp.plugins.pull.zway.ZwayPoll](#pnp.plugins.pull.zway.zwaypoll)
1.25\. [pnp.plugins.pull.zway.ZwayReceiver](#pnp.plugins.pull.zway.zwayreceiver)
2\. [Pushes](#pushes)
2.1\. [pnp.plugins.push.fs.FileDump](#pnp.plugins.push.fs.filedump)
2.2\. [pnp.plugins.push.fs.Zipper](#pnp.plugins.push.fs.zipper)
Expand Down Expand Up @@ -1037,10 +1038,51 @@ __Examples__
push:
- plugin: pnp.plugins.push.simple.Echo

```
<a name="pnp.plugins.pull.net.portprobe-1"></a>

### 1.14\. pnp.plugins.pull.net.PortProbe

Periodically asks a Fritz!Box router for the devices that were connected in the past or right now.

__Arguments__

- **host (str, optional)**: The IP address of your Fritz!Box. Default is 169.254.1.1</br>
- **user (str, optional)**: The user to use. Default is admin.<br/>
- **password (str, optional)**: The password to use. Default is an empty string.

Hint: By using the default values you should be able to connect to your Fritz!Box, because the necessary operation
can be performed anonymously.

__Result__

```yaml
{
"ip": "192.168.178.2",
"mac": "00:0a:95:9d:68:16",
"status": "active",
"name": "pc1"
}
```

__Examples__

```yaml
- name: fritzbox_tracker
pull:
plugin: pnp.plugins.pull.presence.FritzBoxTracker
args:
host: 169.254.1.1 # IP of your Fritz!Box. Default is 169.254.1.1
user: '' # User name. Default is admin
password: admin # Password. Default is an empty string
instant_run: true # ... and run as soon as pnp starts
push:
- plugin: pnp.plugins.push.simple.Echo

```
<a name="pnp.plugins.pull.sensor.dht"></a>

### 1.14\. pnp.plugins.pull.sensor.DHT
### 1.15\. pnp.plugins.pull.sensor.DHT

Periodically polls a dht11 or dht22 (aka am2302) for temperature and humidity readings.
Polling interval is controlled by `interval`.
Expand Down Expand Up @@ -1085,7 +1127,7 @@ __Examples__
```
<a name="pnp.plugins.pull.sensor.miflora"></a>

### 1.15\. pnp.plugins.pull.sensor.MiFlora
### 1.16\. pnp.plugins.pull.sensor.MiFlora

Periodically polls a `xiaomi miflora plant sensor` for sensor readings (temperature, conductivity, light, ...) via btle.

Expand Down Expand Up @@ -1138,7 +1180,7 @@ __Examples__
```
<a name="pnp.plugins.pull.sensor.openweather"></a>

### 1.16\. pnp.plugins.pull.sensor.OpenWeather
### 1.17\. pnp.plugins.pull.sensor.OpenWeather

Periodically polls weather data from the `OpenWeatherMap` api.

Expand Down Expand Up @@ -1236,7 +1278,7 @@ __Examples__
```
<a name="pnp.plugins.pull.sensor.sound"></a>

### 1.17\. pnp.plugins.pull.sensor.Sound
### 1.18\. pnp.plugins.pull.sensor.Sound

Listens to the microphone in realtime and searches the stream for specific sound patterns.
Practical example: I use this plugin to recognize my doorbell without tampering with the electrical device ;-)
Expand Down Expand Up @@ -1311,7 +1353,7 @@ __Examples__
```
<a name="pnp.plugins.pull.simple.count"></a>

### 1.18\. pnp.plugins.pull.simple.Count
### 1.19\. pnp.plugins.pull.simple.Count

Emits every `interval` seconds a counting value which runs from `from_cnt` to `to_cnt`.
If `to_cnt` is None the counter will count to infinity (or more precise to sys.maxsize).
Expand Down Expand Up @@ -1343,7 +1385,7 @@ __Examples__
```
<a name="pnp.plugins.pull.simple.cron"></a>

### 1.19\. pnp.plugins.pull.simple.Cron
### 1.20\. pnp.plugins.pull.simple.Cron

Execute push-components based on time constraints configured by cron-like expressions.

Expand Down Expand Up @@ -1377,7 +1419,7 @@ __Examples__
```
<a name="pnp.plugins.pull.simple.repeat"></a>

### 1.20\. pnp.plugins.pull.simple.Repeat
### 1.21\. pnp.plugins.pull.simple.Repeat

Emits every `interval` seconds the same `repeat`.

Expand Down Expand Up @@ -1406,7 +1448,7 @@ __Examples__
```
<a name="pnp.plugins.pull.traffic.deutschebahn"></a>

### 1.21\. pnp.plugins.pull.traffic.DeutscheBahn
### 1.22\. pnp.plugins.pull.traffic.DeutscheBahn

Polls the Deutsche Bahn website using the `schiene` package to find the next trains scheduled
for a given destination from a specific origin station.
Expand Down Expand Up @@ -1472,7 +1514,7 @@ __Examples__
```
<a name="pnp.plugins.pull.trigger.web"></a>

### 1.22\. pnp.plugins.pull.trigger.Web
### 1.23\. pnp.plugins.pull.trigger.Web

Wraps a poll-based pull and provides a rest-endpoint to externally trigger the poll action.
This will disable the cron-like / scheduling features of the polling component and simply
Expand Down Expand Up @@ -1548,7 +1590,7 @@ curl http://localhost:8080/trigger
```
<a name="pnp.plugins.pull.zway.zwaypoll"></a>

### 1.23\. pnp.plugins.pull.zway.ZwayPoll
### 1.24\. pnp.plugins.pull.zway.ZwayPoll

Pulls the specified json content from the zway rest api. The content is specified by the url, e.g.
`http://<host>:8083/ZWaveAPI/Run/devices` will pull all devices and serve the result as a json.
Expand Down Expand Up @@ -1623,7 +1665,7 @@ Below are some common selector examples to fetch various metrics from various de

<a name="pnp.plugins.pull.zway.zwayreceiver"></a>

### 1.24\. pnp.plugins.pull.zway.ZwayReceiver
### 1.25\. pnp.plugins.pull.zway.ZwayReceiver

Setups a http server to process incoming GET-requests from the Zway-App [`HttpGet`](https://github.com/hplato/Zway-HTTPGet/blob/master/index.js).

Expand Down
39 changes: 39 additions & 0 deletions docs/plugins/pull/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,45 @@ __Examples__
push:
- plugin: pnp.plugins.push.simple.Echo

```
## pnp.plugins.pull.net.PortProbe

Periodically asks a Fritz!Box router for the devices that were connected in the past or right now.

__Arguments__

- **host (str, optional)**: The IP address of your Fritz!Box. Default is 169.254.1.1</br>
- **user (str, optional)**: The user to use. Default is admin.<br/>
- **password (str, optional)**: The password to use. Default is an empty string.

Hint: By using the default values you should be able to connect to your Fritz!Box, because the necessary operation
can be performed anonymously.

__Result__

```yaml
{
"ip": "192.168.178.2",
"mac": "00:0a:95:9d:68:16",
"status": "active",
"name": "pc1"
}
```

__Examples__

```yaml
- name: fritzbox_tracker
pull:
plugin: pnp.plugins.pull.presence.FritzBoxTracker
args:
host: 169.254.1.1 # IP of your Fritz!Box. Default is 169.254.1.1
user: '' # User name. Default is admin
password: admin # Password. Default is an empty string
instant_run: true # ... and run as soon as pnp starts
push:
- plugin: pnp.plugins.push.simple.Echo

```
## pnp.plugins.pull.sensor.DHT

Expand Down
1 change: 1 addition & 0 deletions docs/plugins/pull/README.mdpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
!INCLUDE "docs/plugins/pull/monitor.Stats/index.md", 1
!INCLUDE "docs/plugins/pull/mqtt.Subscribe/index.md", 1
!INCLUDE "docs/plugins/pull/net.PortProbe/index.md", 1
!INCLUDE "docs/plugins/pull/presence.FritzBoxTracker/index.md", 1
!INCLUDE "docs/plugins/pull/sensor.DHT/index.md", 1
!INCLUDE "docs/plugins/pull/sensor.MiFlora/index.md", 1
!INCLUDE "docs/plugins/pull/sensor.OpenWeather/index.md", 1
Expand Down
10 changes: 10 additions & 0 deletions docs/plugins/pull/presence.FritzBoxTracker/example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: fritzbox_tracker
pull:
plugin: pnp.plugins.pull.presence.FritzBoxTracker
args:
host: 169.254.1.1 # IP of your Fritz!Box. Default is 169.254.1.1
user: '' # User name. Default is admin
password: admin # Password. Default is an empty string
instant_run: true # ... and run as soon as pnp starts
push:
- plugin: pnp.plugins.push.simple.Echo
41 changes: 41 additions & 0 deletions docs/plugins/pull/presence.FritzBoxTracker/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# pnp.plugins.pull.net.PortProbe

Periodically asks a Fritz!Box router for the devices that were connected in the past or right now.

Requires extra `fritz` (`pip install pnp[fritz]`) , which is only compatible with python 3.6 or newer.

__Arguments__

- **host (str, optional)**: The IP address of your Fritz!Box. Default is 169.254.1.1</br>
- **user (str, optional)**: The user to use. Default is admin.<br/>
- **password (str, optional)**: The password to use. Default is an empty string.

Hint: By using the default values you should be able to connect to your Fritz!Box, because the necessary operation
can be performed anonymously.

__Result__

```yaml
{
"ip": "192.168.178.2",
"mac": "00:0a:95:9d:68:16",
"status": "active",
"name": "pc1"
}
```

__Examples__

```yaml
- name: fritzbox_tracker
pull:
plugin: pnp.plugins.pull.presence.FritzBoxTracker
args:
host: 169.254.1.1 # IP of your Fritz!Box. Default is 169.254.1.1
user: '' # User name. Default is admin
password: admin # Password. Default is an empty string
instant_run: true # ... and run as soon as pnp starts
push:
- plugin: pnp.plugins.push.simple.Echo

```
29 changes: 29 additions & 0 deletions docs/plugins/pull/presence.FritzBoxTracker/index.mdpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# pnp.plugins.pull.net.PortProbe

Periodically asks a Fritz!Box router for the devices that were connected in the past or right now.

Requires extra `fritz` (`pip install pnp[fritz]`) , which is only compatible with python 3.6 or newer.

__Arguments__

- **host (str, optional)**: The IP address of your Fritz!Box. Default is 169.254.1.1</br>
- **user (str, optional)**: The user to use. Default is admin.<br/>
- **password (str, optional)**: The password to use. Default is an empty string.

Hint: By using the default values you should be able to connect to your Fritz!Box, because the necessary operation
can be performed anonymously.

__Result__

```yaml
{
"ip": "192.168.178.2",
"mac": "00:0a:95:9d:68:16",
"status": "active",
"name": "pc1"
}
```

__Examples__

!INCLUDECODE "docs/plugins/pull/presence.FritzBoxTracker/example.yaml" (yaml)
29 changes: 29 additions & 0 deletions pnp/mocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,35 @@ def fire_event(cls, channel, mode):
cback(channel)


class FritzBoxHostsMock: # pragma: no cover
"""Mocks the fritzconnection.FritzHosts class."""
def __init__(self):
self.address = None
self.user = None
self.password = None

def __call__(self, address, user, password):
"""The actual instantiation of mock from a client perspective."""
self.address = address
self.user = user
self.password = password
return self

@property
def modelname(self):
"""Return the name of the fritzbox model / make."""
return "Fritz!Box Mock v1.0"

def get_hosts_info(self):
"""Return the known hosts."""
_ = self # Fake usage
return [
{"mac": "12:34:56:78:12", 'ip': '192.168.178.10', 'name': 'pc1', 'status': 'active'},
{"mac": "12:34:56:78:13", 'ip': '192.168.178.11', 'name': 'pc2', 'status': ''},
{"mac": "12:34:56:78:14", 'ip': '192.168.178.12', 'name': 'pc3', 'status': 'active'}
]


class PyAudioMock: # pragma: no cover
"""Mocks the pyaudio package (only available with audio devices)."""
class _StreamMock:
Expand Down

0 comments on commit 483c405

Please sign in to comment.