So i am trying to write a logic module that will control my HUE lamps.
By testing via postman and the web evaluate inside the homeserver i know that it can work.
So why not try and make a logic module right?
Code:
# coding: UTF-8 import json import requests ##!!!!################################################################################################## #### Own written code can be placed above this commentblock . Do not change or delete commentblock! #### ######################################################################################################## ##** Code created by generator - DO NOT CHANGE! **## class HUE_Test10801(hsl20_3.BaseModule): def __init__(self, homeserver_context): hsl20_3.BaseModule.__init__(self, homeserver_context, "HUETest") self.FRAMEWORK = self._get_framework() self.LOGGER = self._get_logger(hsl20_3.LOGGING_NONE,()) self.PIN_I_INPUT=1 self.PIN_O_OUTPUT=1 self.FRAMEWORK._run_in_context_thread(self.on_init) ######################################################################################################## #### Own written code can be placed after this commentblock . Do not change or delete commentblock! #### ###################################################################################################!!!## def on_init(self): pass def on_input_value(self, index, value): if self._get_input_value(index) == 1: payload={'on':True} self._set_output_value(self.PIN_O_OUTPUT, 1) elif self._get_input_value(index) == 0: payload={'on':False} self._set_output_value(self.PIN_O_OUTPUT, 0) requests.put('http://"ip adress"/api/"api key"/lights/1/state', json=payload)
However when i import the logic module in Expert 4.8 and attach it to a switch nothing happens. Neither the PUT or the output reacts.
( i tied a switch input to the input of the logic module and the output to a status of that switch)
ie: i press the switch and even the status does not change.
Tried running this code in python command line and it works like a charm.
What am i doing wrong for the homeserver?
Kommentar