LaggAt / ha-jokes

Home Assistant Sensor providing a random joke every minute.
MIT License
18 stars 3 forks source link

Change Poll Time #11

Open tango2590 opened 1 year ago

tango2590 commented 1 year ago

Any chance you can allow the user to determine the poll time (either from a set list or by entering time)? Currently I get a new joke every minute. No big deal, but when I want to show someone, sometimes by the time I get to them it's already changed to a new one.

brianewman commented 1 year ago

I second this. I would like hourly or even daily jokes. My use case is two-fold: First, I keep checking Home Assistant just to see what the joke is and it gets distracting. Secondly, When the joke is funny, I read it to my wife and she gets annoyed because she hates dumb jokes (I love them, of course). Having fewer jokes would distract me less and annoy my wife less.

I was thinking of using a text helper and just copying the joke to it hourly or daily as a workaround, but having a user-selectable interval would be ideal.

Vendo232 commented 1 year ago

agree: set refresh time variable

tango2590 commented 1 year ago

agree: set refresh time variable

I think adding a configuration option would be a great idea. Let the user determine when the jokes get refreshed. Unfortunately, I have no idea how to do that. I did submit a PR to update it from 60 seconds to 15 minutes though. But I like your idea of a user-set update time.

seanmccabe commented 1 year ago

Yer configurable time would be awesome. Plan is to use this once a day in the morning to wake up to :)

CarlBird commented 1 year ago

Just change line 41 in the init.py file: Screenshot_20231203_115020_Home Assistant

mvdwetering commented 7 months ago

The official way to change update intervals in Home Assistant nowadays is to disable the automatic updates and create an automation to trigger when you want updates.

First disable automatic polling. For this go to the integration and open the system settings for the integration (it is in the vertical 3-dot menu). There is a switch to enable polling for automatic updates. Turn off that switch.

Next create an automation that calls the homeassitant.update_entity service. This is my automation. It updates every 15 minutes, but only between 8:00 and 23:00. Change it to your liking.

alias: Update joke
description: ""
trigger:
  - platform: time_pattern
    minutes: /15
condition:
  - condition: time
    after: "08:00:00"
    before: "23:00:00"
    weekday:
      - sun
      - sat
      - fri
      - thu
      - wed
      - tue
      - mon
action:
  - service: homeassistant.update_entity
    data: {}
    target:
      entity_id: sensor.random_joke
mode: single