@tjntomas Thanks you very much for your help :)!
Got it working with the following code :
import appdaemon.plugins.hass.hassapi as hass
from simple_pid import PID
class PIDcalc(hass.Hass):
def initialize(self):
self.run_every(self.PIDrun, "now", 10)
def PIDrun(self, kwargs):
currenttemp= float(self.get_state("climate.trv_zolder", attribute = "current_temperature"))
settemp = float(self.get_state("climate.trv_zolder", attribute = "temperature"))
self.log(currenttemp)
self.log(settemp)
pid = PID(5, 0.2, 0.0, setpoint=settemp)
pid.sample_time = 1
output = round(pid(currenttemp),2)
self.log(output)
self.log("Setting pid.test to PID value")
self.set_state("sensor.pid_zolder",state=output)
It updates every 10 second now.
However it now appears in home assistant with ‘colors’ == state( like on/off )? Instead of a ‘value’( that creates a graph) like normally for a sensor?( check screenshot )
i’ve tried to use the set_value command, however this won’t create a sensor automatically like set_state does? I’ve read that creating a template_sensor manually in HA and then updating it trough AD can cause vague behaviour?
Does my code look OK? I’m starting to understand the AD way of coding I think :)!
Anyway, thanks alot for helping me out in the right direction!!