Skip to content

Instantly share code, notes, and snippets.

@hnykda
Last active December 30, 2021 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnykda/d67c9322f444d39d98286e5b13eddbe2 to your computer and use it in GitHub Desktop.
Save hnykda/d67c9322f444d39d98286e5b13eddbe2 to your computer and use it in GitHub Desktop.
from PyViCare.PyViCare import PyViCare
COMFORT = "comfort"
NORMAL = "normal"
REDUCED = "reduced"
SLEEP = 5
@pyscript_executor
def circuit_factory():
client_id = "fill"
email = "fill"
password = "fill"
vicare = PyViCare()
vicare.initWithCredentials(email, password, client_id, "token.save")
device = vicare.devices[0]
t = device.asAutoDetectDevice()
c = t.circuits[0]
# c.getPrograms()
return c
circuit = circuit_factory()
@pyscript_executor
def _set_program_temperature(name, temperature):
circuit.setProgramTemperature(name, temperature)
#@service
#def set_program_temperature(program_name, temperature):
# _set_program_temperature(program_name, temperature)
@service
def set_default_temperatures(reduced=None, normal=None, comfort=None):
"""yaml
name: Set vicare temperature for given programs
description: Sets a temperature of a specific vicare programs
fields:
reduced:
description: temperature of the reduced program
example: 12
required: false
normal:
description: temperature of the normal program
example: 18
required: false
comfort:
description: temperature of the comfort program
example: 23
required: false
"""
log.info(f"Settings program temperatures: {REDUCED}={reduced}, {NORMAL}={normal}, {COMFORT}={comfort}")
if reduced:
_set_program_temperature(REDUCED, reduced)
task.sleep(SLEEP)
# this didn't help to make it updated
#service.call("pyscript", "set_program_temperature", blocking=True, limit=10, program_name=REDUCED, temperature=reduced)
if normal:
_set_program_temperature(NORMAL, normal)
task.sleep(SLEEP)
if comfort:
_set_program_temperature(COMFORT, comfort)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment