Appdaemon input boolean always null

Hey just wondering if anyone has a workaround for input_booleans. I’m creating a json file to be sent off and use the following to get the state of my switches:

        "lp1_1":self.get_state("inputan.lp1_1"),
        "lp1_2":self.get_state("inputan.lp1_2"),
        "lp1_3":self.get_state("inputan.lp1_3"),
        "lp1_4":self.get_state("inputan.lp1_4"),

which is returning:
lp1_1": null, "lp1_2": null, "lp1_3": null, "lp1_4": null,

I’ve tried to use bool(self.get_state etc…) which returns a constant false.

is there a workaround of this? I could map it into an input_number but that seems a little silly.

These are not valid entity ids. Should be “input_boolean.xxx” not “inputan.xxx”.

Haha yeah i picked on that shortly after posting! still is there a way to change the value to a 1/0 vs a string of “on” “off” i’m handling it on the Arduino side but its a lot of extra code. tried int() but obviously that is not going to work. then there is always the if x=“on” x=1 etc.

You can use the fact that 1 and True are the same in Python.

Try this:

"lp1_1":int(self.get_state("input_boolean.lp1_1") == "on")

thank you so much for that @Burningstone ! scratching my head for a day or so trying to work out the correct syntax