Overhaul command_line tests (#46682)
This commit is contained in:
parent
3ebd5aff98
commit
be8584c0bc
8 changed files with 699 additions and 535 deletions
|
@ -145,19 +145,14 @@ class CommandSensorData:
|
|||
def update(self):
|
||||
"""Get the latest data with a shell command."""
|
||||
command = self.command
|
||||
cache = {}
|
||||
|
||||
if command in cache:
|
||||
prog, args, args_compiled = cache[command]
|
||||
elif " " not in command:
|
||||
if " " not in command:
|
||||
prog = command
|
||||
args = None
|
||||
args_compiled = None
|
||||
cache[command] = (prog, args, args_compiled)
|
||||
else:
|
||||
prog, args = command.split(" ", 1)
|
||||
args_compiled = template.Template(args, self.hass)
|
||||
cache[command] = (prog, args, args_compiled)
|
||||
|
||||
if args_compiled:
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue