Skip to content

Commit

Permalink
Epson projector: *update* simple support for multiple lamps
Browse files Browse the repository at this point in the history
  • Loading branch information
justparking committed Apr 27, 2018
1 parent 7d76ab2 commit b99eafa
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Epson via ESC VP21 protocol/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,14 @@ def local_action_PollErrorState(ignore=None):

# [ lamp hours status

local_event_LampUseHours = LocalEvent({'group': 'Info', 'schema': {'type': 'integer'}})
local_event_LampUseHours = LocalEvent({'group': 'Info', 'desc': 'In hours (space separated for multiple lamps)', 'schema': {'type': 'string'}})

def local_action_PollLampUseHours(ignore=None):
'''{"group": "Info", "order": 2.1}'''
tcp.request('LAMP?', lambda resp: handleValueReq(resp, 'LAMP', lambda value: local_event_LampUseHours.emit(int(value))))
def handleResp(value):
local_event_LampUseHours.emit(value)

tcp.request('LAMP?', lambda resp: handleValueReq(resp, 'LAMP', handleResp))

# poll every 24 hours, 30s first time.
poller_lampHours = Timer(lambda: lookup_local_action('PollLampUseHours').call(), 24*3600, 30)
Expand Down Expand Up @@ -439,7 +442,18 @@ def handleValueReq(resp, name, handler):
local_event_LastContactDetect = LocalEvent({'group': 'Status', 'title': 'Last contact detect', 'schema': {'type': 'string'}})

def statusCheck():
lampUseHours = local_event_LampUseHours.getArg() or 0
# determine lamp hours as a number, may start as a pair e.g. "2132 2133"
allLampsUse = str(local_event_LampUseHours.getArg() or '') # (as string)
multipleLamps = False

# dealing with multiple lamps?
if ' ' in allLampsUse:
# find the max out of multiple lamps
lampUseHours = max([int(x) for x in allLampsUse.split(' ')])
multipleLamps = True

else:
lampUseHours = int(allLampsUse or 0)

diff = (system_clock() - lastReceive[0])/1000.0 # (in secs)
now = date_now()
Expand All @@ -460,7 +474,7 @@ def statusCheck():

elif lampUseHours >= lampUseHoursThreshold:
local_event_Status.emit({'level': 1,
'message': 'Lamp usage is high (%s hours above threshold of %s). It may need replacement soon.' %
'message': 'Lamp usage is high (%s hours above threshold of %s). A replacement may be needed soon.' %
(1+lampUseHours-lampUseHoursThreshold, lampUseHoursThreshold)})

else:
Expand Down

0 comments on commit b99eafa

Please sign in to comment.