Browse Source

add userinteraction check for timeout

master
Andreas Demmelbauer 4 years ago
parent
commit
f1d7f8f819
4 changed files with 13 additions and 1 deletions
  1. +5
    -1
      discobert.py
  2. +7
    -0
      oe1journal.py
  3. BIN
     
  4. +1
    -0
      requirements.txt

+ 5
- 1
discobert.py View File

@@ -335,6 +335,7 @@ def closeService(sleepsecs=0):
sleep(0.1) sleep(0.1)
stopMusic() stopMusic()
inUseBefore = False # Pfusch pfusch! inUseBefore = False # Pfusch pfusch!
hadUserInteraction = False # reset variable
setMode('off') setMode('off')
sleep(sleepsecs) sleep(sleepsecs)


@@ -419,6 +420,7 @@ timeout = 5 * 60 - 5 # timeout since last user interaction
defaultvolume = 90 # Volume when user enters the toilet defaultvolume = 90 # Volume when user enters the toilet
volume = 90 # Global for actual volume volume = 90 # Global for actual volume
uservolume = 90 # Global for user volume (ignores mute state) uservolume = 90 # Global for user volume (ignores mute state)
hadUserInteraction = False #


setSun('off') setSun('off')


@@ -447,7 +449,8 @@ while True:
lastUsed = time.time() lastUsed = time.time()
inUse = True inUse = True
else: else:
if(time.time() > lastUsed + timeout):
# Auto timeout
if(time.time() > lastUsed + timeout and not hadUserInteraction):
inUse = False inUse = False




@@ -457,6 +460,7 @@ while True:


if remotesignal: if remotesignal:
lastUsed = time.time() # user is active! lastUsed = time.time() # user is active!
hadUserInteraction = True
inUse = True inUse = True
for code in remotesignal: for code in remotesignal:
print('received code:', code) print('received code:', code)


+ 7
- 0
oe1journal.py View File

@@ -0,0 +1,7 @@
import requests
from xml.etree import ElementTree as ET

podcast = 'https://files.orf.at/podcast/oe1/oe1_journale.xml'
podcast_string = requests.get(podcast).text
tree = ET.fromstring(podcast_string)
print(tree.find('.//enclosure').get('url'))

BIN
View File


+ 1
- 0
requirements.txt View File

@@ -34,3 +34,4 @@ virtualenv==15.1.0
Werkzeug==0.14.1 Werkzeug==0.14.1
wiringpi==2.46.0 wiringpi==2.46.0
youtube-dl==2019.3.18 youtube-dl==2019.3.18
twisted

Loading…
Cancel
Save