GithubHelp home page GithubHelp logo

rianadon / opensprinkler-card Goto Github PK

View Code? Open in Web Editor NEW
62.0 3.0 7.0 435 KB

Home Assistant card for collecting OpenSprinkler status

License: Other

JavaScript 3.83% TypeScript 96.17%
home-assistant lovelace lovelace-ui opensprinkler

opensprinkler-card's Introduction

Lovelace OpenSprinkler Card

Collect OpenSprinkler status into a card for Home Assistant.

You will need the OpenSprinkler integration installed.

Screenshots

Install

OpenSprinkler Card is available from HACS (search for "opensprinkler card"). If you don't have HACS installed, follow the manual installation instructions.

Options

Name Type Requirement Description
type string Required custom:opensprinkler-card
device string Required Device id of the OpenSprinkler in Home Assistant
name string Optional Card title (e.g. "Sprinkler")
icon string Optional Card icon (e.g. "mdi:sprinkler-variant")
bars dict Optional Configuration for the progress bars
extra_entities array Optional Entities to always show in the card
input_number string Optional Configuration for run-duration-choosing entity
hide_dots bool Optional If true, hide the 3 dots appearing next to entities
hide_disabled bool Optional If true, hide disabled stations and programs in the popup
icons dict Optional Icon configuration. See the default config for an example.

Finding device ids is tricky, so I recommend using the dropdown in the visual card editor to set device rather than YAML.

You can also set popup_line_height, timer_line_height, and card_line_height to control the spacing of entities.

Entity ID requirements

This card locates your OpenSprinkler entities by using their entity ids. If you haven't changed these, you have nothing to worry about.

Otherwise, make sure:

  • The ids of station status sensors end with _status
  • The ids of program running binary sensors end with _running
  • The id of the OpenSprinkler controller enabled switch ends with _enabled
  • The ids of program & station enabled switches end with _enabled
  • The id of the rain delay active binary sensor ends with _rain_delay_active
  • The id of the rain delay stop time sensor ends with _rain_delay_stop_time

Extra entities and duration control

By default, the only way to control stations is to first click on the 3 dots in the top-right corner of the card. If you'd like to have a few stations controls always accessible from the dashboard, you can add them to the bottom of the card with the extra_entities option. You can also add programs or even any entity type (switches, lights, etc).

Screenshot

Stations also default to a runtime of 1 minute. To extend the length they run for, make an input_number entity then link it to the card via the input_number option. The slider or box input will appear in the popup, and if you are using the extra_entities option, in the card as well.

Entity configuration Home Assistant configuration.yaml
type: custom:opensprinkler-card
device: 3e0a97a098f4609215aed92fe19bb7fb
extra_entities:
  - sensor.front_lawn_station_status
  - sensor.arbor_drip_station_status
input_number:
  entity: input_number.slider
input_number:
  slider:
    name: Station Duration
    initial: 5 # in minutes
    min: 1
    max: 30
    step: 1
    # You can also use mode: box

You can also use custom cards for the duration control, like numberbox-card. As well as headings inside the extra_entities! (anything without a . is a heading)

Screenshot
...
input_number:
  entity: input_number.slider
  type: custom:numberbox-card
  unit: m
  icon: mdi:timelapse
extra_entities:
  - Stations
  - sensor.front_lawn_station_status
  - sensor.arbor_drip_station_status
  - sensor.s15_station_status
  - Sensors
  - sensor.opensprinkler_water_level
  - sensor.upstairs_humidity

Progress bar customization

The OpenSprinkler card depends on the Timer Bar Card for rendering progress bars. You can use Timer Bar customization options inside the OpenSprinkler card by inserting your configurations under the bars option. You'll need to switch to the code (YAML) editor to use these options. Fields under the Customization section are supported. For an example:

Screenshot

type: custom:opensprinkler-card
device: 3e0a97a098f4609215aed92fe19bb7fb
name: Sprinkler
bars:
  bar_foreground: pink
  icon: mdi:tortoise
  active_icon: mdi:rabbit

Mobile friendliness

By default, the card is optimized for use with clickers, not fingers. There are a few options you may wish to change if you are a fingerer or touchscreen user:

  • You can space entities further apart to make it more likeley you tap the correct one. For each of the following options, you can use normal (40px spacing, the default in Home Assistant), medium (36px spacing), or small (32px). They are listed with their defaults:
popup_line_height: small # Spacing between entities (sensors, stations, programs) listed in the popup
timer_line_height: medium # Spacing between progress bars (running stations) in the card
card_line_height: small # Spacing between extra_entities (entities in the card)
  • You can hide the 3 vertical dots that appear to the right of station controls using hide_dots, which should further remove some sources of accidents. You can still access entity details by clicking on the station icon (yup, that's not very obvious ... that's why I put the dots there)

A word on design

You may find some details, such as loading icons, the run-once program entry, and the layout of the card in its default configuration to be tastefully designed. You may find other details like the duration input and extra_entities to appear like goblin heads grafted onto puppies. I only have so much time to play around with the design, and welcome any contribution, whether code or Figma link or pencil sketch, to make the card more accessible, consistent, prettier, or whatever you strive for.

Manual installation

  1. Download opensprinkler-card.js from the latest release and move this file to the config/www folder.
  2. Ensure you have advanced mode enabled (accessible via your username in the bottom left corner)
  3. Go to Configuration -> Lovelace Dashboards -> Resources.
  4. Add /local/opensprinkler-card.js with type JS module.
  5. Refresh the page? Or restart Home Assistant? The card should eventually be there.

opensprinkler-card's People

Contributors

cmccambridge avatar rianadon avatar viennaa avatar vinteo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

opensprinkler-card's Issues

OpenSprinkler Enable in extra_entities

When switch.opensprinkler_enabled is included in extra_entities it doesn't affect the entity status:

  1. When switch.opensprinkler_enabled is on, clicking the "stop" icon results in a spinning icon and the entity not turning off
  2. When switch.opensprinkler_enabled is off, the "play" icon is grayed out not clickable

I think ideally, when switch entity is included in extra_entities it would be nice for a toggle switch to be available or else having the icons correctly changing the state.

Thanks.

Manually start program if disabled

I would like to be able to start my program(s) manually even if they are disabled. Currently the "Play button" is greyed out and I have to enable the program first using the switch.

As far as I understand, it is possible to call the opensprinkler.run service even if the program is disabled to start the program once manually.

Any thoughts or reasons why this is not working? Am I missing something?

type: custom:opensprinkler-card
device: 60a146f0e7cae794128d151fc69e362e
name: Rasensprenger
extra_entities:
  - switch.dr_opensprinkler_kurz_program_enabled
  - binary_sensor.dr_opensprinkler_kurz_program_running
input_number:
  entity: input_number.dr_opensprinkler_dauer
  name: Dauer

"Play" greyed out:

grafik

"Play" working only when switch enabled:

grafik

How to put card Title??

Maybe it's very simple but I've been unable to ser card title as the rest of the cards I'm using. Now it's a bit confusing because all the rest have a title but the new opensprinkler card... ?

Thanks in advance.

Feature request: remove the 3 dots showing history

Not sure if this is a HA specific thing, but I'd love to have the 3 dots that shows the station history be a configurable boolean entry.

Why?

  1. I fat finger it all the time!!! (OK, that's probably a personal issue of mine!! hehe)
  2. My wife doesn't need to have more buttons to push that she needs to. It only leads to more questions (OK, this is probably another personal issue!!)

Thanks for your effort. People like you make the whole HA what it is!!

Duration timer bar displays incorrect time when station has started

Just added the card and setup extra_entities to allow ease of starting stations from my phone etc.

Issue is when I start a station with a duration of 1 minute, it shows a durtaion of 5:32. The station only runs for the set time of 1 minute.

What ever I increase the timer by, increases it by that same amout in the duration (appears it adds 4:32 to the actually run time display)

No drop down available to choose device

I have multiple controllers, and when I add a new card, nothing happens when I click on "Required options".

I don't mind editing/working with YAML, can you provide a way to locate the device ID for inserting manually, please?

Weird quirk when an entity is disabled

So, I think I've found them weirdest quirk. Since I only have 4 zones, but I have 8 relays, I wanted to disable the 4 that are unused. It's not about OpenSprinkler, but it's about HA. I just want to keep things clean.

But as soon as one of the entities is disabled, the OS-card doesn't display anymore. In fact, if you go into a dashboard and edit the various cards, it's not even there!

I thought it was user error. For me, 9/10x it is. So, I added another OS-card. At that point, OS-card complains that the device doesn't even exist.

After a lot of trial and error, I figured out that when even one entity is disabled, OS-card goes bye-bye. Even when you re-enable the device only a HA restart will be recognized by the card.

Proposal: Show Rain Delay status on the top-level card

๐Ÿ‘‹ Hi! New to OpenSprinkler, the HACS integration, and this Lovelace card...

At the moment I'm not yet comfortable with how the automatic weather handling algorithms might interact with new seeds in my garden, so I'm managing weather manually with the OpenSprinkler rain delay functionality.

I want to propose the idea of showing the rain delay status on the top-level card while active... similar to the brief banner across the top that you see on the OpenSprinkler home page or mobile app.

I've got a prototype that comes out looking like this... but before I pitch that as a PR, wanted to get your reaction as to whether that's a direction you would be interested in going or not:
image

Thoughts?

Basically looking to extend the high-level view of what's happening with my OpenSprinkler to also include "nothing... because there's a rain delay."

I'm interested in how to actually update the rain delay from Home Assistant as well, but need to dig into whether that's exposed by the API and integration or not. If so, perhaps it can be exposed through the card similar to the manual station time with the input_number support.

input_number not working

I'm not sure if this is a opensprinkler-card issue or a numberbox-card issue.
I have the following opensprinkler-card config:

type: custom:opensprinkler-card
device: abcdefghijklmnopqrstuvwxyz
name: Sprinklers
hide_disabled: true
bars:
  bar_foreground: green
  icon: hass:sprinkler
  active_icon: hass:sprinkler-variant
input_number:
  entity: input_number.slider
  type: custom:numberbox-card
  unit: m
  icon: mdi:timelapse
card_stations:
  - sensor.curb_station_status
  - sensor.front_yard_station_status
  - sensor.side_yard_station_status
  - sensor.s_flower_bed_station_status

For input_number, I have the following in configuration.yaml
input_number: !include input_numbers.yaml
In input_numbers.yaml I have the following:

slider:
  name: Watering Duration
  initial: 15 # in minutes
  min: 0
  max: 30
  step: 5
  # You can also use mode: box

But when I click the run button (right arrow), I see only 1m on the runtime:
image

My apologies if this is not an opensprinkler-card issue.

Station Icons

Wanted to open this for discussion. I have custom icons for my stations but it is not shown as this card uses hardcoded icons. My suggestion is to respect the station icons set on the station entities and use the colour to indicate whether it is running or not, kinda like how light entities work (not sure if possible).

Note the default station has different icons for running/idle but I don't think its possible to use custom icons for two different states through the entity configuration

wrong place for this but i cant figure out..

wasting too much time trying to figure out how to msg you of some sort on github

would like to ask for a refresher in how to go about forking your os-app to my github and using my url for my opensprinkler.

also i have an extremely large homeassistant setup, and appreciate your cards

finally, if at all possible, in opensprinkler software on my pc, when i click a cog on a station, the popup window is just too small for my liking. wishing to do the above for my github fork, where about i do that, or any other advice would be appreciated, ill delete or close this asap

Supporting additional parameters of numberbox-card

Amazing update in v1.6!!

I tried to make my card a little more colorful by using additional parameters from the numberbox-card. So my code editor now shows:

device: <device_id>
name: Sprinklers
hide_disabled: true
bars:
  bar_foreground: green
  icon: hass:sprinkler
  active_icon: hass:sprinkler-variant
input_number:
  entity: input_number.slider
  type: custom:numberbox-card
  unit: m
  icon: mdi:timelapse
  **icon_plus: mdi:chevron-up
  icon_minus: mdi:chevron-down**
extra_entities:
  - Zones
  - sensor.curb_station_status
  - sensor.front_yard_station_status
  - sensor.side_yard_station_status
  - sensor.s_flower_bed_station_status

I took these parameters from the numberbox-card README.md (see the section entitled Examples) where it shows the following (relevant part of the) code:

    type: 'custom:numberbox-card'
    icon_plus: 'mdi:chevron-up'
    icon_minus: 'mdi:chevron-down'
    style: |
      .cur-num{font-size:25px !important}
      .cur-unit{color:orange; font-size:100% !important; opacity:1 !important}
      .grid-left{color:red}
      .grid-right{color:blue}

However, the opensprinkler-card doesn't seem to want to honor the icon_plus or icon_minus parameters. See my screenshot below:
image

I need a little more time, but I can't wait to style the card further, using your timer-bar-card integration.

Remove disabled entities

Hi! Thank you for an amazing card.
I have an 8 station setup, but some of the stations are not setup, so I have disabled them in Home Assistant. However, when I click the 3 dots .. I still see them. Is it possible to remove them? Or at least have a switch to control if they should be displayed on not please? Thanks again ...

image

Duplicate station names not handled correctly

I have two OpenSprinkler controllers - one for the front yard and one for the backyard. There are multiple stations defined for each - 3 and 4, respectively. The remaining stations ("S0x") are unused.

I added both controllers to Home Assistant. There were no problems with the first one (front). However, when I added the second one (back), I only saw two stations instead of eight. I figured out that I only saw the two stations with unique names. The stations with names that were also present in "back" (including all the unused "S0x") were not visible.

I renamed the two stations I cared about, giving them unique names, removed and re-added the controller and the renamed stations are visible now. This makes me think that in a system with multiple sprinkler controllers, duplicate names are not handled properly.

The two controllers have unique names:
os

The entities have unique names as well:
stations

The "front" sprinkler card shows all stations, including the unused ones:
front

The "back" sprinkler card only shows the station with unique names:
back

Might it be a display issue?

Master stations shall not be controllable

Hi!

Would it be possible to disable the control buttons for master stations in the card?
My 8th station is configured for the pump power supply and is, thus, a master station.
It gets activiated by other stations if there is a request for water.

In the OpenSprinkler App it is also NOT controllable.

When I click on the "start/play" button in the card, I get an error from the integration:

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/opensprinkler/__init__.py:324
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 10:01:40 (2 occurrences)
Last logged: 10:05:30

[140258864195568] ('Error code: 48', 48)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1495, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1530, in _execute_service
    await handler.job.target(service_call)
  File "/config/custom_components/opensprinkler/__init__.py", line 104, in _async_send_run_command
    await hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 667, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 863, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 704, in _handle_entity_call
    await result
  File "/config/custom_components/opensprinkler/__init__.py", line 324, in run
    await self._station.run(run_seconds)
  File "/usr/local/lib/python3.9/site-packages/pyopensprinkler/station.py", line 81, in run
    return await self._manual_run(params)
  File "/usr/local/lib/python3.9/site-packages/pyopensprinkler/station.py", line 40, in _manual_run
    content = await self._controller.request("/cm", params)
  File "/usr/local/lib/python3.9/site-packages/pyopensprinkler/__init__.py", line 145, in request
    content = await self._request_http(url)
  File "/usr/local/lib/python3.9/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/pyopensprinkler/__init__.py", line 200, in _request_http
    raise OpenSprinklerApiError(
pyopensprinkler.OpenSprinklerApiError: ('Error code: 48', 48)

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.