Skip to content

Commit

Permalink
Fix sensor incorrect parameter bug
Browse files Browse the repository at this point in the history
  • Loading branch information
edeckers committed Feb 26, 2022
1 parent 07693c8 commit ae23fb7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/zabbix-hue.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/usr/bin/env python3

from fcntl import LOCK_EX, LOCK_NB, flock
from fileinput import filename
import json
import logging
import logging.config
import math
import os
import sys
from tempfile import mkstemp
Expand Down Expand Up @@ -87,7 +85,8 @@ def __cache(self, type: str, fn_call):
lock_file = CachedApi.__tf(f"{temp_filename}.lock")

does_cache_file_exist = exists(cache_file_path)
cache_age_seconds = time.time() - os.path.getmtime(cache_file_path)
cache_age_seconds = time.time(
) - os.path.getmtime(cache_file_path) if does_cache_file_exist else 0
is_cache_file_expired = not does_cache_file_exist or cache_age_seconds >= MAX_CACHE_AGE_SECONDS
is_cache_hit = not is_cache_file_expired

Expand Down Expand Up @@ -286,8 +285,8 @@ def sensor(self, arguments):
LOG.error("Received unknown action '%s' for `sensor` command", action)
return

self.__process(self.__map_sensor(
device_id, CommandHandler.__SENSOR_ACTION_MAP[action](device_id)))
CommandHandler.__process(self.__map_sensor(
device_id, CommandHandler.__SENSOR_ACTION_MAP[action]))
LOG.debug("Finished `sensor` command (arguments=%s)", arguments)

def light(self, arguments):
Expand Down

0 comments on commit ae23fb7

Please sign in to comment.