I'm trying to use autocomplete for the Hass
class from the Python AppDaemon package. Autocomplete is showing some of the inherited methods from the superclass such as get_state()
, but some methods are missing, such as log()
and get_entity()
. This behavior is the same in VS Code and PyCharm Community.
Here's the skeleton of a class I'm writing, which inherits from hass.Hass
:
import hassapi as hass
class AutocompleteTest(hass.Hass):
def initialize(self):
self.get
Here's the class it inherits from (GitHub link):
class Hass(adbase.ADBase, adapi.ADAPI):
The methods I want to autocomplete are in the superclass adapi.ADAPI
(GitHub link). Here are the method definitions from that class:
class ADAPI:
# This method shows in autocomplete
@utils.sync_wrapper
async def get_state(
self,
entity_id: str = None,
attribute: str = None,
default: Any = None,
copy: bool = True,
**kwargs: Optional[Any],
) -> Any:
# This method does not show in autocomplete
def log(self, msg, *args, **kwargs):
# This method does not show in autocomplete
def get_entity(self, entity: str, **kwargs: Optional[Any]) -> Entity:
Can anyone help me understand what's going on, and how to get autocomplete fully working?
My requirements file:
hassapi
iso8601
requests
The hassapi
package on PyPI (hass-api/hassapi) and your requirements file is unaffiliated with AppDaemon.
At runtime, AppDaemon does sys.path.insert(0, plugin)
for its own hass
plugin (AppDaemon/appdaemon/.../appdaemon/plugins/hass) containing the hassapi
module.
To get autocomplete, install appdaemon
package instead.
hassapi
module:# import hassapi as hass
from appdaemon.plugins.hass import hassapi as hass
hassapi.py
in the same directory as autocomplete-test.py containing:from appdaemon.plugins.hass.hassapi import *