Code Monkey home page Code Monkey logo

insteonlocal's Introduction

InsteonLocal

This library is abandoned.

Python library for controlling Insteon Hub locally. This allows you to send direct commands to your Insteon Hub without having to go through the cloud, or obtain a developer API key (which can be hard or impossible to get from Insteon)

Troubleshooting/Reporting

  1. Download the insteon local package from https://github.com/phareous/insteonlocal
  2. Copy config.py.example to config.py and update the host/user/pass to your own hub's information
  3. Edit example.py to call the commands you want to test such as: hub.get_linked() sys.exit(1)
  4. Open an issue at https://github.com/phareous/insteonlocal Include the log file, the list of device models and ID's, and your hub model

Changes

0.54 2022-06-20 Changes to package and requirements to remove built-in package names that could be overwritten by hostile actor

0.53 2017-06-08 Fix typo in error logging

0.52 2017-06-01 Set path for cache files in constructor

0.51 2017-04-08 Use system temp dir

0.50 2017-04-06 Fix cache error parsing [@wardcraigj]

0.49 2017-03-16 Adds support for i2c2 checksums on extended msg, adds support for controlling on/off outlets (2663-222) [@phareous]

0.48 2017-03-09 Fixes with caching and device ids [@phareous]

0.47 2017-03-01 Caching and logging changes [@wardcraigj]

0.46 2017-02-28 More file caching changes [@wardcraigj]

0.45 2017-02-28 Switching caching to be file-based [@wardcraigj]

0.44 Bug fix for caching [@wardcraigj]

0.43 Better caching [@wardcraigj]

0.41 Add support for FanLinc, better status support [@jawilson]

0.40 Added caching to get device status [@wardcraigj]

0.39 Initial stable release for use in Home Assistant

Hubs

This was developed and tested against the Insteon Hub 2245-222.

It may work for the Insteon Hub 2242-222, SmartLinc 2414N, or other hub with a HTTP local API. However, it has not been tested with these hubs.

Devices

This version of the library should work with Insteon dimmers and switches, and FanLinc controls. It was developed against 2466SW ToggleLinc Relay (Switch) and 2477D SwitchLinc Dual-Band Dimmer

Unsupported Devices

At this time, these devices are supported:

-Switches -Dimmers -Receptacles -FanLinc

To add support for future devices, we will need donations of equipment, or for device owners to directly contribute code.

Unsupported devices include (but aren't limited to):

  • Keypads
  • Thermostats
  • Garage Door Interface
  • Leak Detector
  • Pool Devices
  • Open/Close Sensor
  • Door Sensor
  • Motion Sensor
  • Sprinkler Interfaces
  • Smoke Bridge
  • I/O Module
  • Micro Dimmer
  • On/Off Micro
  • Open/Close Micro
  • Ballast Dimmer
  • In-line Dimmer
  • Mini Remote

Functionality

The library can currently do the following actions:

  • Switches:

    • On
    • Off
    • Beep
  • Dimmers:

    • On (specified level)
    • On (fast: saved level)
    • Off
    • Off instant
    • Change level
    • Brighten one step
    • Dim one step
    • Start changing (up or down)
    • Stop changing (up or down)
    • Beep
  • Groups:

    • On
    • Off

For all devices, you can get the status of a device with getStatus which will query the device and return the result

You can request a list of all linked devices. For each device, it will also return the type of device and the model. This is accomplished by using two files from this library, device_categories.json and device_models.json

Missing Functionality

It is suggested to use the mobile Insteon App for features that are missing from the library:

  • You cannot link or unlink devices to your hub

  • You cannot modify, create, or remove scenes/groups.

  • You cannot change settings (operating flags) on a device (ramp rate, led brightness, beep, etc.)

  • The library does not recognize double-tap, etc.

  • The library cannot respond to broadcasts from devices that change state (aka instant notification when you turn on a switch). This could probably be accomplished by the calling application polling the getBufferStatus but it may require library changes to respond to the proper insteon command type.

Using the Library

Because scene, room, and device names are stored in the cloud, they are not available to this library. You can use the getLinked() command to get a list of device ids, and their models/categories, and then store these locally in your application with the desired friendly names, etc.

The first thing to do is to instiniate a hub object:

hub = Hub(ip, user, pass, port, log filename/path, enable console log (Tru eor False))

Example:

hub = Hub('192.168.1.16', 'myuser', 'mypass', '25105', '/tmp/insteonlocal.log', True)

The port is normally 25105. The user/pass is on a sticker on the bottom of the hub (but can be changed via the mobile app). The IP address is available via the mobile app

After establishing a connection to the hub, you can create a Switch or Dimmer object (by giving the Insteon ID). See the example.py for examples.

Establish dimmer and turn on to 25%:

dimmer1 = hub.dimmer('41902d')
dimmer1.on(25)

Turn on switch:

switch1 = hub.switch('40465a')
switch1.on()
switch1.off()

Turn on group:

group3 = hub.group("3")
group3.on()

insteonlocal's People

Contributors

camrun91 avatar craigjmidwinter avatar jawilson avatar phareous avatar

Stargazers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

insteonlocal's Issues

Max Listeners

I am getting the following error in my log. I had no issues until today and no config change was made, the devices just stopped reporting status and not responding to state changes.

(node:3248) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connect listeners added to [Insteon]. Use emitter.setMaxListeners() to increase limit
(Use node --trace-warnings ... to show where the warning was created)

Dimmers flicker

Few weeks in to Home Assistant.. Loaded the insteon lights and switches. I have 16 lights/dimmers 7switches several firmware versions and types.
Hub 2245-222.

It seems the polling/checking states causes a lot of traffic. I have noticed when homeassistant is running several of my dimmers flicker randomly.So we'll see the lights turn off and on <1 second. When I turn off homeassistant/insteon config they no longer flicker. Is there a way to slow down how often it checks states?

Vanilla install..
Has anyone ran into this?

Thanks!

Cache not being used

This library becomes extremely slow and unreliable once I add > 10 devices. I tried to debug and found that cache is not being used.

I added a debug line around line 447/448 in Hub.py and found this:

get_device_status for device 43****
INFO:homeassistant.components.insteon_local:key 1900 not in command cache
INFO:homeassistant.components.insteon_local:no cached status for device 43****

I tried to rebuild the cache at this point, but that did not solve the issue.Any idea what would cause this?

I am using HA in virtualenv.

Add HTTP status code check

INFO:insteonlocal.Hub:getBufferStatus: Got raw text with size 35 and contents: 401 Unauthorized: Password required INFO:insteonlocal.Hub:postDirectCommand: http://192.168.1.2:25105/1?XB=M=1 INFO:insteonlocal.Hub:clearBuffer: <Response [401]> OrderedDict([('error', False), ('success', True), ('message', ''), ('msgs', [OrderedDict([('im_code', '1 ')]), OrderedDict([('im_code', 'au')]), OrderedDict([('im_code', 'or')]), OrderedDict([('im_code', 'ed')]), OrderedDict([('im_code', 'Pa')]), OrderedDict([('im_code', 'wo')]), OrderedDict([('im_code', ' r')]), OrderedDict([('im_code', 'ui')])])])
INFO:insteonlocal.Hub: Dimmer 2F25FD status: None

Empty string from status

I've got the Home Assistant working to toggle locally, however, in order to get status, I have to comment out line 308 of Hub.py otherwise I get an empty string for raw_text and a nonetype returned. Was this just needed to trim the trailing zeros?

(raw_text value starts with a zero when I'm stepping through)

Typo causing logging to fail.

https://github.com/phareous/insteonlocal/blob/master/insteonlocal/Dimmer.py#L106

Please replace the %S with %s

Jun 05 18:54:53 mozart docker[1232]: ValueError: unsupported format character 'S' (0x53) at index 8
Jun 05 18:54:53 mozart docker[1232]: Call stack:
Jun 05 18:54:53 mozart docker[1232]:   File "/usr/local/lib/python3.6/threading.py", line 884, in _bootstrap
Jun 05 18:54:53 mozart docker[1232]:     self._bootstrap_inner()
Jun 05 18:54:53 mozart docker[1232]:   File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
Jun 05 18:54:53 mozart docker[1232]:     self.run()
Jun 05 18:54:53 mozart docker[1232]:   File "/usr/local/lib/python3.6/threading.py", line 864, in run
Jun 05 18:54:53 mozart docker[1232]:     self._target(*self._args, **self._kwargs)
Jun 05 18:54:53 mozart docker[1232]:   File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 66, in _worker
Jun 05 18:54:53 mozart docker[1232]:     work_item.run()
Jun 05 18:54:53 mozart docker[1232]:   File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
Jun 05 18:54:53 mozart docker[1232]:     result = self.fn(*self.args, **self.kwargs)
Jun 05 18:54:53 mozart docker[1232]:   File "/usr/src/app/homeassistant/components/light/insteon_local.py", line 178, in turn_on
Jun 05 18:54:53 mozart docker[1232]:     self.node.change_level(brightness)
Jun 05 18:54:53 mozart docker[1232]:   File "/usr/local/lib/python3.6/site-packages/insteonlocal/Dimmer.py", line 107, in change_level
Jun 05 18:54:53 mozart docker[1232]:     level)
Jun 05 18:54:53 mozart docker[1232]: Message: 'Dimmer %S change_level: level %s'

No links in pypi

Hey,
re: home-assistant/core#3811
I'm getting started on trying to integrate this with HomeAssistant and https://pypi.python.org/simple/insteonlocal/ seems to be empty resulting in an error when trying to pip install or include in requirements.txt.

I was able to install it by pip install git+https://github.com/phareous/insteonlocal.git but unfortunately the requirements parser seems to barf on that, so I can't really include it properly.

In the issue on the hass project you had mentioned are a PHP developer by trade. I work as a PHP dev too and this is the first real python project I'm trying to dig my teeth into, so unfortunately I don't have any experience with pip and can't offer any quick fixes.

MaxListnersExceededWarning

I am getting the following error in my log. I had no issues until today and no config change was made, the devices just stopped reporting status and not responding to state changes.

(node:3248) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connect listeners added to [Insteon]. Use emitter.setMaxListeners() to increase limit
(Use node --trace-warnings ... to show where the warning was created)

Security issue in insteonlocal latest versions - Possible Supply Chain Attack

Impact of the bug
Malicious code execution

Describe the bug
There are an unmet dependency in setup.py and requirements.txt - library pprint:

https://github.com/phareous/insteonlocal/blob/master/setup.py#L14

https://github.com/phareous/insteonlocal/blob/master/requirements.txt#L3

Despite pprint library is built-in, it can be reinstalled using pypi if:

  • someone will register it
  • version of this library will be more than built-in, e.g. 112.0

For now, this package does not registered:

python -m pip install pprint
ERROR: Could not find a version that satisfies the requirement pprint (from versions: none)
ERROR: No matching distribution found for pprint

Affected versions:
At least insteonlocal 0.53 and 0.52 are affected (the latest one).

Solution:
Need to delete these potential unsafe packages from pypi and probably publish new version without these verbose dependencies.

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.