GithubHelp home page GithubHelp logo

chickenandpork / hass-osbee Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 24 KB

Simple integration for OpenSprinkler Bee (OSBee) irrigation controller in Home Assistant

License: MIT License

Python 100.00%
hacs home-assistant home-assistant-integration opensprinkler

hass-osbee's Introduction

hass-osbee

Simple integration for OpenSprinkler Bee (OSBee) irrigation controller in Home Assistant

This is currently a hack-together integration for the OpenSprinkler "OSBee" in the most basic sense. It has limited configurability, and sub-optimal config, but it's a start. Using this integration, one or more OSBee should appear as:

  • Sensor showing Wifi RSSI power
  • Binary Sensor for each zone, showing whether it's running
  • Switch for each zone, allowing to turn on/off.

In current form, one OSBee creates one sensor, 3 binary_sensors, 3 switches, all named "osbee "; for example, with MacAddreaa c4:5b:be:12:34:56, you'll see:

  • sensor "osbee c45bbe123456 rssi" showing Received Signal strength (in dB) (so -20dB is 1% of full power, -30dB is 0.1%)
  • binary_sensor "osbee c45bbe123456 zone 0" showing whether zone 1 is running/open/on
  • binary_sensor "osbee c45bbe123456 zone 2" showing whether zone 2 is running/open/on
  • binary_sensor "osbee c45bbe123456 zone 3" showing whether zone 3 is running/open/on
  • switch "osbee c45bbe123456 zone 0" through which you can turn on zone 1
  • switch "osbee c45bbe123456 zone 1" through which you can turn on zone 2
  • switch "osbee c45bbe123456 zone 2" through which you can turn on zone 3

OSBee runs sprinklers for a preset time, so these switches turn on until turned off, or until 30 minutes has passed. Every time you turn on or off a zone, the 30-minute max is reset.

Currently, the auth token is hard-coded to the default, and the logs are REALLY SPAMMY; I'll clean those up soon. Yes, that default token is in the documentation for OSBee.

Errors, feature-requests

Please file a github issue: https://github.com/chickenandpork/hass-osbee/issues/new

This is volunteer work, but I want to improve this integration to help more people. If there's a bug, issue, or feature-request, please file it as a github issue. If there sparse documentation doesn't explain, file an issue, and we can figure it out together, perhaps improving the code to be more intuitive, perhavps adding more documentation.

How to Use

This is currently a hack-together integration for the OpenSprinkler "OSBee" to appear as sensor(s), switches, and binary sensor; it's currently tested as YAML config because that's currently the easiest way to unittest. More details in the file "docs/YAML-CONFIGS.md" in the repo.

Where I Want the Config to Be

My goal was to configure as a simple osbee: block like this, but we're not there yet:

osbee:
  - host: 192.168.1.77
    token: BobIsAGiant
  - host: 192.168.2.44
    token...

To reiterate, we're not there yet, but that's where I'd like to be. I know that YAML concerns some people, and Home-Assistant seems to be eliminating all text config, but until it's completely banned, this is what works so very well.

Configuring the Current Code

Right now, this current release, you will need to make redundant platform configs per-entity. For example, assuming you have two OSBees (on 192.168.1.44 and 192.168.1.45), and 1.44 can run for a maximum of 45 minutes (2700 seconds), but 1.45 keeps the default 15-minute window. Tokens for 1.44 and 1.45 are "BobIsAGiant" and "AllanIsTheKing", respectively.

binary_sensor:
  - platform: osbee
    host: 192.168.1.44
    timeout: 2700
    token: BobIsAGiant
  - platform: osbee
    host: 192.168.1.45
    token: AllanIsTheKing

sensor:
  - platform: osbee
    host: 192.168.1.44
    timeout: 2700
    token: BobIsAGiant
  - platform: osbee
    host: 192.168.1.45
    token: AllanIsTheKing

switch:
  - platform: osbee
    host: 192.168.1.44
    timeout: 2700
    token: BobIsAGiant
  - platform: osbee
    host: 192.168.1.45
    token: AllanIsTheKing

What about Config Flow?

I found the most difficulty in config_flow. Really, it's documented in a way that likely makes sense once you know it, but it's hard for a beginning Home-Assistant Integration-Developer to decipher (I've been coding a long long time, not necessarily well, but new to Home-Assistant's flavour of python).

As well, the examples don't work, and there's a lot of magic stuff that's not explained. I don't think my coding preferences align with Python in general (I like strong-typing both to catch errors AT BUILD TIME plus as a documentation benefit) and python is really the other extreme. ...so I'm doing my best.

This was maybe the 7th or 8th iteration of building this as an integration. I don't know if I got the config schema for config_flow correct in every one.

If you really want Config-Flow, please file a Github Issue discussing it. I'll know you use this integration, get a brief ego-boost, and get an idea of what you're doing and how I can maybe help.

Text-Based Configs

see "docs/YAML-CONFIGS.md" in the repo.

hass-osbee's People

Contributors

chickenandpork avatar renovate[bot] avatar

Watchers

 avatar  avatar  avatar

hass-osbee's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/hassfest.yaml
  • actions/checkout v3

  • Check this box to trigger a request for Renovate to run again on this repository

hass-osbee connection issue, bug?

Hi,

It looks like I have run into a bug:

  • OSBee Firmware v1.0.2
  • Core 2024.4.3
  • Supervisor 2024.04.0
  • Operating System 12.2
  • Frontend 20240404.2
  • HACS: "version": "1.34.0"
  • hass-osbee: "version": "0.0.2"

hass-osbee downloaded via git clone

Install path:

/homeassistant/custom_components/osbee/

Logs:

/homeassistant/configuration.yaml:

# Loads default set of integrations. Do not remove.
default_config:

binary_sensor:
  - platform: osbee
    host: 192.168.xx.xx
    token: xxxxx 

sensor:
  - platform: osbee
    host: 192.168.xx.xx
    token: xxxxx

switch:
  - platform: osbee
    host: 192.168.xx.xx
    token: xxxxx

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

/homeassistant/home-assistant.log:

2024-04-16 08:35:45.260 WARNING (MainThread) [custom_components.osbee.osbeeapi] type of timeout/max_runtime is <class 'int'>
2024-04-16 08:35:45.260 WARNING (MainThread) [custom_components.osbee.osbeeapi] created OSBeeAPI at 192.168.xx.xx max_runtime 1800 (<class 'int'>)
2024-04-16 08:35:45.279 ERROR (MainThread) [custom_components.osbee.coordinator] In coordinator.py::OSBeeHubCoordinator::Exception on api::fetch_data 0, message='Attempt to decode JSON with unexpected mimetype: application/json', url=URL('http://192.168.2.33/jc')
Traceback (most recent call last):
  File "/config/custom_components/osbee/coordinator.py", line 46, in _async_update_data
    return await self.my_api.fetch_data(listening_idx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/osbee/osbeeapi.py", line 61, in fetch_data
    jc_body = await jc_request.json(content_type="text/html")
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 73, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1176, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: application/json', url=URL('http://192.168.xx.xx/jc')
2024-04-16 08:35:45.287 ERROR (MainThread) [custom_components.osbee.coordinator] In coordinator.py::OSBeeHubCoordinator::Exception on api::fetch_data Server disconnected
Traceback (most recent call last):
  File "/config/custom_components/osbee/coordinator.py", line 46, in _async_update_data
    return await self.my_api.fetch_data(listening_idx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/osbee/osbeeapi.py", line 40, in fetch_data
    async with self._session.get(f"http://{self._host}/jc") as jc_request:
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1194, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 605, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 976, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/streams.py", line 640, in read
    await self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: Server disconnected
2024-04-16 08:35:45.754 ERROR (MainThread) [custom_components.osbee.coordinator] In coordinator.py::OSBeeHubCoordinator::Exception on api::fetch_data 0, message='Attempt to decode JSON with unexpected mimetype: application/json', url=URL('http://192.168.xx.xx/jc')
Traceback (most recent call last):
  File "/config/custom_components/osbee/coordinator.py", line 46, in _async_update_data
    return await self.my_api.fetch_data(listening_idx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/osbee/osbeeapi.py", line 61, in fetch_data
    jc_body = await jc_request.json(content_type="text/html")
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 73, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1176, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: application/json', url=URL('http://192.168.xx.xx/jc')

I would appreciate any help as I would like to get this up and running.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.