timer-bar-card icon indicating copy to clipboard operation
timer-bar-card copied to clipboard

Hello there is no problem, rather a question.

Open kotana opened this issue 3 years ago • 17 comments

How can I use this identity attribute? Thanks in advance. image

kotana avatar Jun 23 '21 15:06 kotana

It should work by providing only the duration:

type: custom:timer-bar-card
entities:
  - binary_sensor.irrigation_unlimited_c1_m
duration: { attribute: current_duration }

Let me know if this doesn't work / is inaccurate. The time_remaining in your screenshot looks of use, but I don't know how often it is updated.

rianadon avatar Jun 23 '21 18:06 rianadon

Unfortunately it does not work. It just shows me the current status. on or off. image image

kotana avatar Jun 24 '21 14:06 kotana

Double check you are on version 1.3! I've been adding the features to make this work very recently.

Otherwise, your configuration looks correct.

rianadon avatar Jun 24 '21 17:06 rianadon

Hi, I now have version V1.4 Unfortunately it does not work. Only the status is displayed.

kotana avatar Jun 25 '21 05:06 kotana

I'm sorry I really have no idea why this is not working.

I've released another version that's added a debugging mode for showing what the card thinks the duration & time remaining are. It would be helpful if you could upgrade again, add debug: true to your configuration, and paste/screenshot the debugging information.

Not that I think it would make much difference to the problem at hand, but since your card has a current_start attribute, you could supply this config:

type: custom:timer-bar-card
entities:
  - binary_sensor.irrigation_unlimited_c1_m
duration: { attribute: current_duration }
start_time: { attribute: current_start }

Thanks for spending time on this!

rianadon avatar Jun 25 '21 06:06 rianadon

Here is a screenshot of the debug image

Oh by the way, dark theme does not work properly, the font cannot recognize mn in (debug mode) image image

kotana avatar Jun 25 '21 10:06 kotana

Aha! I see the problem! Looks like I have a bug duration didn't add correctly to compute the time remaining (-22.785 seconds + 0:01:00 duration, or 60 seconds = 37.215 seconds, not -22.7850:01:00.

I've fixed this problem in v1.6. Hopefully this one should solve the problem!

rianadon avatar Jun 25 '21 18:06 rianadon

Hi, so far everything works. But there is still a problem with the filter or display.

filter is true ( everything is ok, i started nothing ) image

filter is true ( everything is ok, started the process ) image

filter is true ( everything is ok, process stopped, but the time continues. ) image image

but when I press the F5 key everything is ok again.

If the filter is false this error does not happen.

Can I hide the icon and name? If not, is that possible?

Oh yes, I have something else .. :) Is that possible to implement? image

kotana avatar Jun 26 '21 07:06 kotana

Yikes. I know what the problem is.

For weekdays, timers, and next_trigger, did you have in mind any designs of how these should be shown?

rianadon avatar Jun 26 '21 18:06 rianadon

simple text is sufficient for weekdays.

Timers: think also as text

next_triger: as a bar

kotana avatar Jun 28 '21 05:06 kotana

Hmm I can't visualize how I could fit this all into one row, unless you'd like to draw me something.

For the text parts, A template sensor might fulfill your needs. Something like:

template:
  - sensor:
    - name: "Times"
      icon: mdi:clock
      state: >
        {% set weekdays = state_attr('switch.schedule_nachsaat_4x_taglich, 'weekdays') %}
        {% set times = state_attr('switch.schedule_nachsaat_4x_taglich, 'times') %}
         
        {{ weeekdays }} at {{ times }}

For next_trigger, from when would the bar start counting down? (that is, if next_trigger is the end time, what would be the start time?) You could set only end_time, which means the card would use the time last changed as the start time, but I don't know if that's what you want.

rianadon avatar Jun 28 '21 18:06 rianadon

Thanks for this issue, I'm using Irrigation Unlimited integration too and this worked like a charm. Maybe it would be a good idea to add it to the readme near the use with openSprinkler ;)

luixal avatar Apr 23 '23 16:04 luixal

Thanks for the suggestion! I added a link to the readme.

rianadon avatar Apr 23 '23 18:04 rianadon

I still have to polish some things on the irrigation unlimited side, such as how to get total irrigation remaining time (instead of per zone) so I can also show a timer-bar for the whole irrigation sequence.

If you like, I can make a PR with examples and how to set it up :)

Just let me know if you prefer me adding a section in the readme, or should I add a new md file and link it in the readme.

luixal avatar Apr 24 '23 10:04 luixal

The problem I'm facing is that the whole sequence duration is stored into an attribute in a yaml format, within an array. I can get the value using this template:

{{ state_attr('binary_sensor.irrigation_unlimited_c1_m', 'sequence_status')[1].duration }}

But I have no idea how to pass that duration to the timer-bar card, can you help @rianadon ?

Thanks!

PS: I wouldn't like to create a sensor/helper/entity for duplication this value, just get it from the attribute.

luixal avatar Apr 24 '23 13:04 luixal

Yes, please! A PR with your examples would be much appreciated. If it's short I'd prefer the readme, otherwise I'd prefer you make another issue with the integration doc label and link it to the readme. That way there's a spot for anyone who has questions to ask them.

Dealing with arrays is not something I expect to ever support in the card. If you'd like to avoid creating another sensor, maybe the config template card would help you pass in the value. I've never played with the card before, but it would be really awesome to see if it works.

This is a very rough example, but perhaps something along these lines:

type: 'custom:config-template-card'
variables:
  DURATION: states['binary_sensor.irrigation_unlimited_c1_m'].attributes.sequence_status[1].duration
entities:
  - binary_sensor.irrigation_unlimited_c1_m
card:
  type: custom:timer-bar-card
  entities:
    - binary_sensor.irrigation_unlimited_c1_m
  duration: { fixed: "${DURATION}" }
  start_time: { attribute: current_start }

rianadon avatar Apr 24 '23 20:04 rianadon

Hi,

Well, 2 stones, 1 bird, I had plans of playing around with config-template-card so... I can confirm timer-bar works without a problem. Here's my working example:

- type: custom:config-template-card
  variables:
  DURATION: >-
    states['binary_sensor.irrigation_unlimited_c1_m'].attributes.sequence_status[1].duration
  START_TIME: >-
    states['binary_sensor.irrigation_unlimited_c1_m'].attributes.sequence_status[1].start
  entities:
    - binary_sensor.irrigation_unlimited_c1_m
  card:
    type: custom:timer-bar-card
    entity: binary_sensor.irrigation_unlimited_c1_m
    icon: none
    active_icon: mdi:sprinkler-variant
    duration:
      fixed: ${DURATION}
      units: seconds
    start_time: ${START_TIME}

Anyhow, as irrigation goes on, time doesn't match accurately, but that's a problem on Irrigation Unlimited integration I think. Due to that , it has no sense to show the timer-bar and a percentage bar would be enough.

luixal avatar Apr 25 '23 13:04 luixal