Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to access Controller variables? #92

Closed
jaydeel opened this issue Mar 24, 2024 · 6 comments
Closed

Possible to access Controller variables? #92

jaydeel opened this issue Mar 24, 2024 · 6 comments

Comments

@jaydeel
Copy link

jaydeel commented Mar 24, 2024

Is it possible to access the Controller's variables (API Keyword /jc)

I'd like to test if the controller is disabled before sending a station.run command.
Currently, the API (v2.3.3) ignores the disable operation setting when executing station.run.

The relevant /jc return variable appears to be 'en' (Operationenablebit).

@vinteo
Copy link
Owner

vinteo commented Mar 24, 2024

The switch that controls that variable is switch.<contoller_name>_enabled which by default is switch.opensprinkler_enabled. You can check the state of that

@jaydeel
Copy link
Author

jaydeel commented Mar 24, 2024

I've tried the following and get an error:

controller_is_enabled = switch.opensprinkler_enabled
NameError: name 'switch' is not defined

How do I define 'switch'?

@vinteo
Copy link
Owner

vinteo commented Mar 24, 2024

oh sorry i thought this was the other repo.

try

controller_is_enabled = self._controller._get_variable('en')

@jaydeel
Copy link
Author

jaydeel commented Mar 25, 2024

Thanks. I'm a Python novice and not sure how to define 'self' in my current implementation.
Here's my code...

import asyncio
from aiohttp import ClientSession
from pyopensprinkler import Controller as OpenSprinklerController
async def main() -> None:
     async with ClientSession() as session:
        controller = OpenSprinklerController(OPENSPRINKLER_URL, OPENSPRINKLER_PASSWORD)
        ...

@vinteo
Copy link
Owner

vinteo commented Mar 25, 2024

then it should be just

controller.enabled

may need to do a controller.refresh() before checking

@jaydeel
Copy link
Author

jaydeel commented Mar 25, 2024

Perfect! Thx!

@jaydeel jaydeel closed this as completed Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants