10000 Consider user defined scan_interval for command_line sensor. by bliemli · Pull Request #2994 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Consider user defined scan_interval 8000 for command_line sensor. #2994

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

Closed
wants to merge 2 commits into from
Closed

Conversation

bliemli
Copy link
@bliemli bliemli commented Aug 26, 2016

Description:
Remove hard coded scan_interval of 60s so the command_line sensor considers either the default value of 30s or a user defined value, as expected according to https://home-assistant.io/topics/platform_options/#scan-interval.

@arsaboo
Copy link
Contributor
arsaboo commented Aug 26, 2016

Does this mean that the user can add the add the scan_interval in the config? That will be super.

@bliemli
Copy link
Author
bliemli commented Aug 26, 2016

Yes, exactly. Sorry I didn't include an example config, I thought this was unnecessary because according to the documentation linked in the description, this should have already been possible.

@arsaboo
Copy link
Contributor
arsaboo commented Aug 26, 2016

There are other sensors that have a similar restriction (e.g., Rest Sensor). Will it affect them as well?

@bliemli
Copy link
Author
bliemli commented Aug 26, 2016

No, this change is specific to the command_line sensor.

@kellerza
Copy link
Member

Can you try to make the default 60 seconds?

Adding a PLATFORM_SCHEMA with vol.Optional('SCAN_INTERVAL', default=60) should do the trick (there are many voluptuous PRs currently open that you can use as examples

@robbiet480
Copy link
Member

@bliemli Make @kellerza's change and then this is good to merge in time for 0.27! 👍

@Teagan42
Copy link
Contributor

👍

@bliemli
Copy link
Author
bliemli commented Aug 27, 2016

Thank you all for the input/feedback. Will try to do that.

@arsaboo
Copy link
Contributor 8000
arsaboo commented Aug 27, 2016

I was thinking that it will be nice to make similar changes to the REST sensor (provide user defined scan_interval). I can create a PR if that is something we would like to see.

@balloob
Copy link
Member
balloob commented Sep 1, 2016

Instead of using a schema, just add SCAN_INTERVAL = timedelta(seconds=60) and the entity component will automatically pick it up: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/helpers/entity_component.py#L87-L90

@robbiet480
Copy link
Member

@bliemli When you get @balloob's comment fixed, along with the merge conflict fixed, we can get this merged!

@bliemli
Copy link
Author
bliemli commented Sep 5, 2016

If I understand that right, it's probably the easiest approach to just abort this pull request and open a new one. The merge of pr #2968 fundamentally changed the command_line sensor (and all other command_line components). Other suggestions?

@kellerza
8000 Copy link
Member
kellerza commented Sep 5, 2016

git fetch --all & git rebase upstream/dev should be all you need and then continue

@bliemli
Copy link
Author
bliemli commented Sep 5, 2016

Hmm. My two commits in here are unnecessary as they changed things from the previous version. So even though I'd take out all changes while rebasing, these commits would remain in the logs. Still ok?

@kellerza
Copy link
Member
kellerza commented Sep 5, 2016

Yes, just continue on your branch and make sure the end result is fine. Then we'll squash when you're done and it will look like a single commit

@Teagan42
Copy link
Contributor
Teagan42 commented Sep 7, 2016

@bliemli Mind fixing merge conflicts?

@bliemli
Copy link
Author
bliemli commented Sep 7, 2016

@Teagan42 No, not at all. I just wanted to be sure it's ok to leave unnecessary commits in there. Thanks :)

@bliemli
Copy link
Author
bliemli commented Sep 8, 2016

I just tested the command_line sensor's behaviour from the dev branch without changing anything. It now considers the scan_interval as expected, so @fabaff's changes to use voluptuous already solved this :)
That also means I'm closing my PR. Thanks everyone for the support!

@bliemli bliemli closed this Sep 8, 2016
@fanaticDavid
Copy link
Contributor

I can't confirm that this is working correctly, unless I'm missunderstanding how it works.

Take the following sensor as an example:

- platform: command_line
  name: "Hombot Status"
  command: "python3 /home/hass/.homeassistant/python/hombot_retrieve_status.py 'JSON_ROBOT_STATE'"
  scan_interval: 10
  value_template: "{{ value | capitalize() }}"

When I run cat /var/log/syslog | grep JSON_ROBOT_STATE, this is what I find:

Sep 25 02:43:50 Ra hass[648]: INFO:homeassistant.components.sensor.command_line:Running command: python3 /home/hass/.homeassistant/python/hombot_retrieve_status.py 'JSON_ROBOT_STATE'
Sep 25 02:45:00 Ra hass[648]: INFO:homeassistant.components.sensor.command_line:Running command: python3 /home/hass/.homeassistant/python/hombot_retrieve_status.py 'JSON_ROBOT_STATE'
Sep 25 02:46:10 Ra hass[648]: INFO:homeassistant.components.sensor.command_line:Running command: python3 /home/hass/.homeassistant/python/hombot_retrieve_status.py 'JSON_ROBOT_STATE'
Sep 25 02:47:20 Ra hass[648]: INFO:homeassistant.components.sensor.command_line:Running command: python3 /home/hass/.homeassistant/python/hombo
8000
t_retrieve_status.py 'JSON_ROBOT_STATE'
Sep 25 02:48:30 Ra hass[648]: INFO:homeassistant.components.sensor.command_line:Running command: python3 /home/hass/.homeassistant/python/hombot_retrieve_status.py 'JSON_ROBOT_STATE'

Another sensor as an example:

- platform: command_line
  name: "Hombot Battery"
  command: "python3 /home/hass/.homeassistant/python/hombot_retrieve_status.py 'JSON_BATTPERC'"
  unit_of_measurement: '%'
  scan_interval: 30

And the output of cat /var/log/syslog | grep JSON_BATTPERC looks like this:

Sep 25 02:45:00 Ra hass[648]: INFO:homeassistant.components.sensor.command_line:Running command: python3 /home/hass/.homeassistant/python/hombot_retrieve_status.py 'JSON_BATTPERC'
Sep 25 02:46:30 Ra hass[648]: INFO:homeassistant.components.sensor.command_line:Running command: python3 /home/hass/.homeassistant/python/hombot_retrieve_status.py 'JSON_BATTPERC'
Sep 25 02:48:00 Ra hass[648]: INFO:homeassistant.components.sensor.command_line:Running command: python3 /home/hass/.homeassistant/python/hombot_retrieve_status.py 'JSON_BATTPERC'
Sep 25 02:49:30 Ra hass[648]: INFO:homeassistant.components.sensor.command_line:Running command: python3 /home/hass/.homeassistant/python/hombot_retrieve_status.py 'JSON_BATTPERC'
Sep 25 02:51:00 Ra hass[648]: INFO:homeassistant.components.sensor.command_line:Running command: python3 /home/hass/.homeassistant/python/hombot_retrieve_status.py 'JSON_BATTPERC'

So looking at the timestamps above, it turns out the actual interval is scan_interval + 60 seconds. I am running the latest stable version of HASS, being 0.28.2.

@fanaticDavid
Copy link
Contributor

Still seeing the same behaviour on 0.29.6. Any feedback on this? Or should I open a new issue myself?

@bliemli
Copy link
Author
bliemli commented Oct 2, 2016

You're right, this is not yet working, I probably tested a cached version...
I'll look into fixing this as soon as I have the time, though I can't say when this will be.

@fanaticDavid
Copy link
Contributor
fanaticDavid commented Oct 2, 2016

I'd try to fix it myself if I was clever enough but I'm not lol. So looking forward to a fix, @bliemli

I did find a 8000 "dirty fix" in related issue #2499, but I agree with @slash5k1 over there that a rewrite is probably in order.

EDIT: seems I may have worked it out after all! Now to see if I can figure out how to make a PR 😉

@fanaticDavid
Copy link
Contributor

@bliemli You're more than welcome to fix it if you're up for it. Unfortunately, my PR #3652 was closed. Oh well, I was in way over my head anyway...

@michaelarnauts
Copy link
Contributor

Any reason why this PR was closed? I still notice the behavior that the interval is 70 seconds when I specify 10 seconds as scan_interval...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants
0