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

Add soil moisture % sensor #133

Open
sethhere04 opened this issue May 18, 2022 · 9 comments
Open

Add soil moisture % sensor #133

sethhere04 opened this issue May 18, 2022 · 9 comments
Assignees

Comments

@sethhere04
Copy link

Is it possible to add the soil moisture % as a sensor reported to HA?

@sebr
Copy link
Owner

sebr commented May 19, 2022

@sethhere04 I don't have any of these devices so unfortunately I can't add them. If you are willing to share your account (or create a new one) with me I could take a look.

@sethhere04
Copy link
Author

Sorry, its not a separate device. It’s just the soil moisture % reported in the bhyve app. I was wondering if there is a way to see that in HA.

@AnthonyBe
Copy link

I came here to ask the exact same question!

@sebr
Copy link
Owner

sebr commented May 22, 2022

Got it, will take a look and see what I can do!

@allistermaguire
Copy link
Contributor

Hey @sebr, not sure if this is helpful, but moisture is part of the landscape object which you can get with the get_landscape() function. You need to calculate it, percentage = available_water / (field_capacity_depth - replenishment_point) * 100

@doe81
Copy link

doe81 commented Oct 5, 2022

+1 on this feature.

@kdeyev
Copy link

kdeyev commented Aug 21, 2023

+1

@kdeyev
Copy link

kdeyev commented Aug 26, 2023

@allistermaguire
Hi, I tried to implement the soil moisture sensor in this integration. But there's something wrong with the bhyve API or the way I calculate the moisture value:

import asyncio

import aiohttp

import pybhyve 

async def async_update_callback(data):
    pass


async def main() -> None:
    """Main."""
    
    websession = aiohttp.ClientSession()

    client = pybhyve.Client(
        "login",
        "passwd",
        session=websession,
    )

    if await client.login() is False:
        raise Exception()

    loop = asyncio.get_event_loop()

    client.listen(loop, async_update_callback)
    all_devices = await client.devices
    for device in all_devices:
        device_id = device["id"]
        for zone in device['zones']:
            zone_id = zone["station"]
            res = await client.get_landscape(zone_id=zone_id, device_id=device_id, force_update=True)
            percentage = res["available_water"] / (res["field_capacity_depth"] - res["replenishment_point"]) * 100
            print(percentage)


loop = asyncio.get_event_loop()
loop.run_until_complete(main())

I have 5 zones and all the 5 moisture values were the same 47%, but the Android app shows meaningful moisture values.
Do you have any idea how the app calculates these values?

@allistermaguire
Copy link
Contributor

Hi @kdeyev, I have had a look and I was mistaken, I assumed 'available_water' could be used to retrieve level as well as set it, but that is not the case.

Looking at it more from what I can capture from the app, it looks like it is calculated from the 'watering_plan' returned from api.orbitbhyve.com/v1/sprinkler_timer_programs.

When I get some time I will see if I can work it out.

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

6 participants