Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to version 1.2.3 #21

Merged
merged 47 commits into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ad7f63f
* added command /turnon_automation to turn on automation
foxcris May 11, 2020
8f809f4
* added command /state_automation to display the state of all automat…
foxcris May 11, 2020
18f8cf3
- shortened /clb_*_automation to /clb_*_autom as callbacks with teleg…
foxcris May 11, 2020
c14e419
- fixed some errors with automation commands
foxcris May 11, 2020
9dc84a0
- Fixed some error with turn on/off automations
foxcris May 11, 2020
e00db86
- added support for compute of traveltime from current position to de…
foxcris May 31, 2020
13495ea
Merge branch 'master' of https://github.com/foxcris/appdaemon-telegra…
foxcris May 31, 2020
8cc2d68
- added reply mechanism to retrive traveltime from waze
foxcris Jun 1, 2020
b3e2c07
- added unit test for travel time computation
foxcris Jun 1, 2020
f772b28
- updated readme to include travel time computation for location mess…
foxcris Jun 1, 2020
586e243
- updated readme with configuration parameters for travel time comput…
foxcris Jun 1, 2020
816d29b
Merge branch 'master' of https://github.com/foxcris/appdaemon-telegra…
foxcris Jun 1, 2020
b67b763
- added command get_log
foxcris Jun 4, 2020
ceb27f1
Create python-pytest.yml
foxcris Jan 10, 2021
cd4e0ec
Create stale.yml
foxcris Jan 10, 2021
339c973
Added configuration to close stale issues and pr requests
foxcris Jan 14, 2021
cba89d7
Bump aiohttp from 3.6.2 to 3.7.4
dependabot[bot] Feb 26, 2021
da77f50
Bump py from 1.8.1 to 1.10.0
dependabot[bot] Apr 20, 2021
fd8b7af
Bump urllib3 from 1.25.9 to 1.26.5
dependabot[bot] Jun 2, 2021
8a26baf
Merge pull request #14 from foxcris/dependabot/pip/aiohttp-3.7.4
foxcris Sep 14, 2021
6898041
Merge pull request #18 from foxcris/dependabot/pip/urllib3-1.26.5
foxcris Sep 14, 2021
3813471
Merge pull request #17 from foxcris/dependabot/pip/py-1.10.0
foxcris Sep 14, 2021
bd2d7b7
Bump pyyaml from 5.1 to 5.4
dependabot[bot] Sep 14, 2021
318b0fd
Merge pull request #16 from foxcris/dependabot/pip/pyyaml-5.4
foxcris Sep 14, 2021
3f773ca
Bump jinja2 from 2.10.1 to 2.11.3
dependabot[bot] Sep 14, 2021
3b77a42
Merge pull request #15 from foxcris/dependabot/pip/jinja2-2.11.3
foxcris Sep 14, 2021
5d9ca89
Create codeql-analysis.yml
foxcris Sep 14, 2021
26a1da7
- added config option extend_light
foxcris Sep 14, 2021
27481e5
Merge branch 'master' of https://github.com/foxcris/appdaemon-telegra…
foxcris Sep 14, 2021
80e8940
- using generic turn_on and turn_off function
foxcris Sep 14, 2021
7642f10
- start using poetry
foxcris Dec 12, 2021
a732d20
using poetry
foxcris Dec 12, 2021
08a4b97
- set Version to 1.2.1
foxcris Dec 20, 2021
09256f0
Merge branch 'master' of https://github.com/foxcris/appdaemon-telegra…
foxcris Dec 20, 2021
5ef0136
- using poetry now to handle dependencies
foxcris Dec 20, 2021
459b261
- added appdaemon as dependency
foxcris Dec 20, 2021
51aeddc
- fixed syntax error
foxcris Dec 21, 2021
6d7f984
Update README.md
GeitjeG Dec 21, 2021
f456ef6
Update README.md
GeitjeG Dec 21, 2021
1e1dfd7
Update README.md
GeitjeG Dec 21, 2021
620a6e2
Update README.md
GeitjeG Dec 21, 2021
826ecf9
Merge pull request #20 from GeitjeG/master
foxcris Dec 22, 2021
b67cdd7
Update README.md
foxcris Dec 22, 2021
373e2ae
- added test for filter_whitelist, filter_blacklist
foxcris Feb 21, 2022
afc0160
Merge branch 'master' of https://github.com/foxcris/appdaemon-telegra…
foxcris Feb 21, 2022
7cb40f2
- updated all required python packages to the current versions
foxcris Feb 21, 2022
0a0b44b
- remove Helper Class from apps.yml
foxcris Feb 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '33 20 * * 4'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
33 changes: 33 additions & 0 deletions .github/workflows/python-pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
ci:
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
poetry-version: [1.0, 1.1.12]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run image
uses: abatilo/[email protected]
with:
poetry-version: ${{ matrix.poetry-version }}
- name: prepare environment
run: poetry install
- name: run pytest
run: poetry run pytest .
25 changes: 25 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Mark stale issues and pull requests

on:
schedule:
- cron: "30 1 * * *"

jobs:
stale:

runs-on: ubuntu-latest

steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 60
days-before-close: 30
stale-issue-message: 'Marked this issue as stale. Without any further activity it will be closed in 30 days.'
close-issue-message: 'Issue closed. No activity in the last 30 days.'
stale-pr-message: 'Marked this pull request as stale. Without any further activity it will be closed in 30 days.'
close-pr-message: 'Pull request closed. No activity in the last 30 days.'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
remove-stale-when-updated: true

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,4 @@ venv.bak/

# mypy
.mypy_cache/
.vscode/settings.json
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "helper"]
path = helper
url = https://github.com/foxcris/appdaemon-helper.git
74 changes: 0 additions & 74 deletions Helper.py

This file was deleted.

58 changes: 41 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,59 @@ Currently the bot provides a simple request/response command interface. The foll
* /state_system: State of home-assistant
* /state_sensor: State of sensors
* /get_version: Get version of telegrambot
* /turnon_automation: Turn on automation
* /turnoff_automation: Turn off automation
* /trigger_automation: Trigger automation
* /state_automation: State of automation
* send location message from telegram: for each defined zone in home-assistant the travel time from the current location sent is computed

## Configuration
### appdaemon configuration
Just copy the files
1: Just copy the following files to your /appdaemon/apps dir.
* TelegramBot.py
* Helper.py

to your apps folder of appaemon and add the following configuration to your apps.yaml (example data shown for some parameters)
2: Please take care that you checkout out all used submodules of the project. [Here](https://openmetric.org/til/programming/git-pull-with-submodule/) is a good explanation how to do that. Otherwise get Helper.py from https://github.com/foxcris/appdaemon-helper and copy it to the local helper dir.

3: Copy the following folders to your /appdaemon/apps dir:
* helper
Only the Helper.py script is needed. All other files are used during development.

4: To your apps folder of appaemon and add the following configuration to your apps.yaml (example data shown for some parameters)
```
TelegramBot:
module: TelegramBot
class: TelegramBot
debug: True
extend_system: sensor.date,sensor.heartbeat
filter_blacklist:
- load_1m
- load_5m
extend_light: switch.light
filter_blacklist:
- unwanted_entity
- another_unwanted_entity
filter_whitelist:
- sample
```
routing:
waze:
region: EU
avoid_toll_roads: True
hass:
token: !secret ha_token
ha_url: http://hass:8123
```
The token is stored i a separate secret.yml file. However you can also directly enter the token.

extend_system: comma separated list of complete entities to include in the system report
filter_blacklist: python regex to exclude entities from being reported/used from telegrambot
filter_whitelist: python regex to whitelist entities from being reported/used from telegrambot
The following logic is used to apply the blacklist and whitelist:
* If the blacklist is empty - nothing is filtered out
* If the whitelist is empty - nothing is filtered out
* If both the blacklist and whitelist are non-empty, first the blacklist ist applied and then the whitelist
| Configuration parameter | Description |
| ------------- | ------------- |
|extend_system | comma separated list of complete entities to include in the system report|
|extend_light | comma separated list of complete entities to include in the commands /state_light /turnoff_light /turnon_light|
|filter_blacklist| List of python regex to exclude entities from being reported/used from telegrambot. As the most simple regex you can just list all entities you want to remove.|
|filter_whitelist| List of python regex to whitelist entities from being reported/used from telegrambot. Becareful, mosttime you do not want to use this!
|routing| currently only waze is supported. region can be 'US','EU','IL','AU' and is used to select the correct routingserver from waze. avoid_toll_roads is a boolean to enable/disable the use of toll roads in the travel time computation.|
|hass| the url and port of home assisstant, for example http://192.168.1.31:8123. The ha_token is a long-lived access token you have to create for the plugin to communicate with HA. You can create it in HA in the administrator section of HA (login to admin account, than in the left pane the lowest button: administrator, scroll to bottom: long-live acces token).|

The file Helper.py is also used by one of my [other](https://github.com/foxcris/appdaemon-blinds-control) appdaemon project. In both projects the same file is used!
The following logic is used to apply the blacklist and whitelist:
- If the blacklist is empty - nothing is filtered out
- If the whitelist is empty - nothing is filtered out
- If both the blacklist and whitelist are non-empty, first the blacklist ist applied and then the whitelist

## Screenshots
<img src="https://raw.githubusercontent.com/foxcris/appdaemon-telegrambot/master/images/Screenshot_20190310_123130_org.telegram.messenger.jpg" width="250">
Expand All @@ -67,8 +90,9 @@ The file Helper.py is also used by one of my [other](https://github.com/foxcris/

### Tests

For the unit test the [Appdamon-Test-Framework](https://github.com/FlorianKempenich/Appdaemon-Test-Framework) is used together with [pytest](https://docs.pytest.org/en/latest/).
For the unit test the [Appdamon-Test-Framework](https://github.com/FlorianKempenich/Appdaemon-Test-Framework) is used together with [pytest](https://docs.pytest.org/en/latest/).
I am using some addition features of the framework which are currently not merged in the original repository. My own fork, which i use for development can be found [here](https://github.com/foxcris/Appdaemon-Test-Framework).

### Requirements

All necessary requirements are listed in the `requirements-dev.txt`
All necessary requirements are listed in the `pyproject.toml`. I use [poetry](https://python-poetry.org/) to handle virtual environments.
Loading
Loading