GithubHelp home page GithubHelp logo

dcmeglio / homeassistant-petsafe Goto Github PK

View Code? Open in Web Editor NEW
28.0 28.0 7.0 60 KB

Integrate PetSafe Smartfeed feeders an Scoopfree litter boxes into Home Assistant.

Python 100.00%
cats dogs feeder litterbox petsafe

homeassistant-petsafe's People

Contributors

cmccambridge avatar dcmeglio avatar hanscats 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

Watchers

 avatar  avatar  avatar  avatar

homeassistant-petsafe's Issues

Detected Blocking call

I have lots of examples of the following in my home assistant.log

2024-06-20 09:52:31.258 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open inside the event loop by custom integration 'petsafe' at custom_components/petsafe/SensorEntities.py, line 232: feeding = await feeder.get_last_feeding() (offender: /usr/local/lib/python3.12/gzip.py, line 192: fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')), please create a bug report at https://github.com/dcmeglio/homeassistant-petsafe/issues
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/usr/src/homeassistant/homeassistant/main.py", line 223, in
sys.exit(main())
File "/usr/src/homeassistant/homeassistant/main.py", line 209, in main
exit_code = runner.run(runtime_conf)
File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever
self._run_once()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, in _run_once
handle._run()
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self.args)
File "/usr/src/homeassistant/homeassistant/core.py", line 828, in async_create_task_internal
task = create_eager_task(target, name=name, loop=self.loop)
File "/usr/src/homeassistant/homeassistant/util/async
.py", line 37, in create_eager_task
return Task(coro, loop=loop, name=name, eager_start=True)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 941, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1289, in async_device_update
await self.async_update()
File "/config/custom_components/petsafe/SensorEntities.py", line 232, in async_update
feeding = await feeder.get_last_feeding()

Connected Pet Door

Is there any way this integration can be modified so that it shows the PetSafe Connect Pet Door? Point me in the right direction and I may figure it out.

Integration Causes Poor Performance After Upgrade to Home Assistant Core 2024.7.x

It appears that on 2024.7.0 and 2024.7.1 (at the time of this writing), this integration causes more than double CPU usage and causes the web UI for HA to be non-responsive and slow. Disabling this integration returns the CPU usage and responsiveness back to normal.

See this issue for Home Assistant Core reporting this problem.

In my case, upgrading to 2024.7.0 resulted in the CPU usage going from 4-12% (pre-upgrade) up to 26-33%. Disabling this integration returned CPU usage back to normal.

Bug report from HA 2024.

Showed up after recent HA upgrade"

Running HA on:

Operating System: CentOS Stream 9
CPE OS Name: cpe:/o:centos:centos:9
Kernel: Linux 5.14.0-437.el9.x86_64
Architecture: x86-64
Hardware Vendor: Intel_R_ Client Systems
Hardware Model: NUC10i7FNH

Logger: homeassistant.util.loop
Source: util/loop.py:84
First occurred: 5:49:51 PM (746 occurrences)
Last logged: 5:53:19 PM

Detected blocking call to open inside the event loop by custom integration 'petsafe' at custom_components/petsafe/init.py, line 269: self._feeders = await self.api.get_feeders() (offender: /usr/local/lib/python3.12/gzip.py, line 192: fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')), please create a bug report at https://github.com/dcmeglio/homeassistant-petsafe/issues Traceback (most recent call last): File "/srv/homeassistant/bin/hass", line 8, in sys.exit(main()) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/main.py", line 209, in main exit_code = runner.run(runtime_conf) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 651, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 618, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1951, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 84, in _run self._context.run(self._callback, *self.args) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/core.py", line 828, in async_create_task_internal task = create_eager_task(target, name=name, loop=self.loop) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/util/async.py", line 37, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 941, in async_update_ha_state await self.async_device_update() File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 1289, in async_device_update await self.async_update() File "/home/homeassistant/.homeassistant/custom_components/petsafe/SwitchEntities.py", line 133, in async_update return await super().async_update() File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/update_coordinator.py", line 529, in async_update await self.coordinator.async_request_refresh() File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/update_coordinator.py", line 262, in async_request_refresh await self._debounced_refresh.async_call() File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/debounce.py", line 111, in async_call if task := self.hass.async_run_hass_job( File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/core.py", line 939, in async_run_hass_job return self._async_add_hass_job(hassjob, *args, background=background) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/core.py", line 748, in async_add_hass_job task = create_eager_task( File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/util/async.py", line 37, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/update_coordinator.py", line 288, in async_refresh await self._async_refresh(log_failures=True) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh self.data = await self._async_update_data() File "/home/homeassistant/.homeassistant/custom_components/petsafe/init.py", line 269, in _async_update_data self._feeders = await self.api.get_feeders()
Detected blocking call to open inside the event loop by custom integration 'petsafe' at custom_components/petsafe/SensorEntities.py, line 232: feeding = await feeder.get_last_feeding() (offender: /usr/local/lib/python3.12/gzip.py, line 192: fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')), please create a bug report at https://github.com/dcmeglio/homeassistant-petsafe/issues Traceback (most recent call last): File "/srv/homeassistant/bin/hass", line 8, in sys.exit(main()) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/main.py", line 209, in main exit_code = runner.run(runtime_conf) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 651, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 618, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1951, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 84, in _run self._context.run(self._callback, *self.args) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/core.py", line 828, in async_create_task_internal task = create_eager_task(target, name=name, loop=self.loop) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/util/async.py", line 37, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 941, in async_update_ha_state await self.async_device_update() File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 1289, in async_device_update await self.async_update() File "/home/homeassistant/.homeassistant/custom_components/petsafe/SensorEntities.py", line 232, in async_update feeding = await feeder.get_last_feeding()
Detected blocking call to open inside the event loop by custom integration 'petsafe' at custom_components/petsafe/init.py, line 270: self._litterboxes = await self.api.get_litterboxes() (offender: /usr/local/lib/python3.12/gzip.py, line 192: fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')), please create a bug report at https://github.com/dcmeglio/homeassistant-petsafe/issues Traceback (most recent call last): File "/srv/homeassistant/bin/hass", line 8, in sys.exit(main()) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/main.py", line 209, in main exit_code = runner.run(runtime_conf) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 651, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 618, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1951, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 84, in _run self._context.run(self._callback, *self._args) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/update_coordinator.py", line 288, in async_refresh await self._async_refresh(log_failures=True) File "/srv/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh self.data = await self._async_update_data() File "/home/homeassistant/.homeassistant/custom_components/petsafe/init.py", line 270, in _async_update_data self._litterboxes = await self.api.get_litterboxes()`

Unable to create triggers or graphs for ScoopFree sensor data

I have configured a "scoopefree2". I can see sensor data in the device config for "Last Cleaning", "Rake Counter", and "Rake Status". I seem to be able to create some graphs for "Last Cleaning" and "Rake Status", but can't seem to create triggers for any of them.

I would've expected creating triggers for Rake Counter exceeding an amount (or even a timer with the Rake Counter as a condition) would be a pretty logical thing, but it seems these sensor values aren't actually being made available correctly.

I might see if I can poke around a bit and see if I can find out what's going on, but figured I'd log this first in case someone better versed might have an idea off-hand what it might be.

Home Assistant services don't work for first generation Smart Feeder

Hello!

I believe I have a first generation PetSafe Smart Feeder, purchased in 2018, and that it has an interesting discrepancy versus the second generation: My feeder doesn't have a product_name in its JSON device object from the smart-feed/feeders API endpoint. (See below)

This causes all of the scheduling services to fail, as well as causing the service target to show empty lists for Areas containing a feeder and the Devices list itself. ๐Ÿ›

Following that root cause forward, the fallout in code is:

  • in petsafe library: petsafe.devices.DeviceSmartFeed.product_name is None
  • in the HA integration: each PetSafeFeederXXXXEntity sets up its device info with model = None
  • ...so, is_device_feeder always returns False since the model doesn't match "SmartFeed_2.0"
  • ...so, get_feeders_by_device_id returns an empty list
  • ...so, get_feeders_for_services returns an empty list
  • ...so, each of the service handlers fails to take any action, as they have no devices to act on!

Here's my full JSON result from smart-feed/feeders, having replaced only the id and thing_name:

[
    {
        "id": 12345,
        "serial": null,
        "thing_name": "a-123456789abc",
        "battery_voltage": "24698",
        "region": "",
        "connection_status": 2,
        "is_food_low": 0,
        "is_adapter_installed": true,
        "is_batteries_installed": true,
        "firmware_version": "V1.1.0.9",
        "product_name": null,
        "revision_desired": 325,
        "revision_reported": 325,
        "food_sensor_current": 0,
        "food_sensor_reference": 0,
        "network_snr": 58,
        "network_rssi": -32,
        "connection_status_timestamp": "2023-01-12T14:46:47.000Z",
        "created_at": "2018-11-14 00:54:36",
        "settings": {
            "friendly_name": "Food Robot",
            "paused": false,
            "slow_feed": true,
            "child_lock": true,
            "notify_on_feed": true,
            "notify_on_connection_state_change": true,
            "notify_on_low_food": true,
            "notify_on_empty_food": true,
            "notify_on_error": true,
            "notify_on_community_message": true,
            "timezone": "America/Chicago",
            "pet_type": "cat",
            "updated_at": "2022-08-06 12:45:04"
        },
        "schedules": [
            {
                "id": 253178,
                "amount": 2,
                "time": "06:00",
                "updated_at": "2022-11-06 07:03:34"
            }
        ]
    }
]

Add amount

Hallo
Pls add an amount dropdown field.

Integration keeps losing connection

Integration was working for a couple of weeks flawlessly. Was asked to reconfigure, which I did assuming maybe there was a 30 day token and now it asks me to reconfigure every 5 minutes.

Petsafe integration not triggering 'feed' button

This is a ver. 1 SmartFeed device. All or most of the entities generated report correct status or in the case of unavailable functions such as 'food level', a reasonable status. The 'button.feed' entity does trigger the button.press service but the feeder does not respond. The logger does report the action. Some of the 'switch' entries work but the status is reported with significant latency. For instance, if the 'child lock' entity is triggered, the toggle shows 'on' then after a few seconds returns to 'off' then after 5-6 seconds returns to 'on.'
The major issue here is the 'button.feed' entity does not work at all. Calling the 'button.press' service from the Developer Tools page has the same result. There are some log entries that may relevant.

Source: helpers/entity_platform.py:536
Integration: Sensor (documentation, issues)
First occurred: 10:42:50 AM (8 occurrences)
Last logged: 10:51:27 AM

Platform petsafe does not generate unique IDs. ID m-D0C5D3142225_battery already exists - ignoring sensor.kittyfood_battery_level
Platform petsafe does not generate unique IDs. ID m-D0C5D3142225_last_feeding already exists - ignoring sensor.kittyfood_last_feeding
Platform petsafe does not generate unique IDs. ID m-D0C5D3142225_food_level already exists - ignoring sensor.kittyfood_food_level
Platform petsafe does not generate unique IDs. ID m-D0C5D3142225_signal_strength already exists - ignoring sensor.kittyfood_signal_strength
Logger: homeassistant.components.button
Source: helpers/entity_platform.py:536
Integration: Button (documentation, issues)
First occurred: 10:42:50 AM (2 occurrences)
Last logged: 10:51:27 AM

Platform petsafe does not generate unique IDs. ID m-D0C5D3142225_ already exists - ignoring button.kittyfood_feed

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.