I am having a speed fan and its oscillation_output required a child of BinaryGpioOutput. So I made an output with platform gpio, and it worked. But now I want to control this swing from lambda. What I found is gpio output doesn’t have state attribute, so id(my_output).state don’t work. There is only method for setting the state, not read the current state. Then I create an switch with platform output. From lambda I can toggle the state of this switch, but then it only turn off the output if it is currently on, not vice versa.
Ok, I think I understood, the problem is to verify state?
I don’t think there is function for that, but you can work around with help of global variable
It’s not only for verifying, the simple case is I want to toggle the output, but toggle method is not available as well as get state method. So how can we toggle without knowing the current state?
It’s the same approach as mine, create a switch with the given output. First, it’s over complicate compared with directly getting the state of the output. Second, it doens’t work for me. I used lambda to toggle the state of the switch, it updated on the frontend ui, but the actual output pin does not turn on. If I use the frontend to toggle the switch, the output turn on.
It’s not overly complicated. The pin is set to output mode and thus you can’t read the input. Why complicate the output component with unnecessary state handling when there’s other components that already does that.
I don’t see any lambda turning on the switch in the config you’ve posted?
Oh I got the idea about that concept, I just simply thought that because of this switch I have to add the switch: component, which lead to a lot of file will be use while compiling, I don’t like that. Now it become rational.
Thanks for your info.
I dont put the lambda code because it can be anywhere :v