Closed apowers313 closed 10 months ago
Hi @apowers313 thanks for the interest in this project. I'm afraid I need to spend a bit of time reminding myself about it as its been dormant for some time.
My immediate answer is I think yes you do need those fields and for the example device GS308EP I show the values for them here https://gilesknap.github.io/maaspower/main/explanations/devicetypes.html#id1
Those are the values that I got working pretty well with my GS308EP and this is the only device that the web scrape approach has been tested against!
To be clear - this web gui approach is connecting to the WebUI provided by the device and poking its buttons and reading back fields from the GUI pages. So you do need to tell MaasPower what to poke and what to read in order to switch ports on and off and to read back status.
Thanks for the quick reply (and for the awesome project)!
WebGui requires on / off / query? Or WebDevice? It was WebGui that failed the schema check for me.
Also, I bought the same switch as you to try and make my life easier, so no problems there. :)
Ah OK, I see you are correct. I can also see what the issue is. https://github.com/gilesknap/maaspower/blob/8293da94d8cb89b3680abcab789c39d0c0a4a8de/src/maaspower/devices/web_ui.py#L34-L43
WebGUI is derrived from SwitchDevice so inherits the unnecessary fields. So a little bit of a re-think needed there.
However your workaround of supplying dummy values is fine.
@apowers313 by the way, are you building an RPI cluster or do you using this for something else?
Copying the WebGui example from this page: https://gilesknap.github.io/maaspower/main/explanations/devicetypes.html#web-gui-control
Leads to a schema validation error. It appears that the JSON schema for WebGui requires the fields "name", "on", "off", and "query"; however, the last three of those probably aren't required for a WebGui device (are they?). After adding those three fields with a dummy string, the JSON passes schema validation.