Code Monkey home page Code Monkey logo

webthings-mysensors-adapter's Introduction

MySensors-adapter

This is an adapter for the Mozilla WebThings Gateway that allows it to connect to MySensors devices.

MySensors is an Arduino framework that makes it easy to create your own smart devices, such as sensors for your smart home. They are generaly connected wirelessly, and can form a mesh network together, allowing the network to reach further. https://www.mysensors.org

This adapter connects your MySensors network to the Mozilla WebThings Gateway, which is an open source smart home controller built by the Mozilla Foundation. You might know them from the Firefox webbrowser. It allows you to control devices in your home, log their data, and create home automations. It has an easy to user interface. https://github.com/mozilla-iot/gateway

This adapter is built on top of the pyMySensors library by Theo Lind. This great library does the heavy lifting, and turns messages from the network into an easy to use stream of updates. This adapter turns that stream of messags into devices in the gateway. https://github.com/theolind/pymysensors

It was created as part of the Candle project, which aims to create a prototype of a smart home that is much more privacy friendly that existing solutions. It's goal is to show that you can have a home that is both smart and privacy friendly. https://www.createcandle.com

Status

It currently supports most sensor inputs, as well as most actuators.

Missing or just partially implemented are:

  • IR sender/receiver

Version 0.0.2 added the ability to select different radio gateways (serial, ethernet, MQTT), and had some improvements to property support.

Version 0.0.3 adds persistence, in the sense that handed out node ID's are remembered.

Version 0.0.4 makes persistance selectable, and adds the ability to send a discover command to all nodes so that they re-present themselves. This is done at start and when the user clicks on the (+) button. It also improves the temperature property's presentation.

Version 0.0.5 improves type support, implements smarter device removal, makes persistance work as you'd expect (recreates nodes as soon the gateway is restarted), and better implements capabilities support from the Mozilla IoT schema.

Version 0.0.6 added a debug option.

Version 0.0.7 fixed an issue where prefered capability to be centrally displayed was forgotton when the add-on restarted. Also removes the persistence option, and replaces it with the option to show a device as connected only after receiving a signal from it.

Version 0.0.8 made reading the configuration more robust, but introduced a bug.

Version 0.0.9 removed that bug, and then turned into:

Version 0.1.0 rewrote how persistence works in an attempt to fix an issue a user was having.

Version 0.1.1 tried to anticipate small changes in the upcoming version (0.9) of the WebThings gateway.

Version 0.1.2 added

  • Automatic serial port searching. User doesn't need to add a serial port ID manually anymore (but can if they want)
  • Support for metric/imperial units. You can set your preference in the add-on settings.
  • Support for multipleOf. This should help show a sane amount of decimals on numeric variables.
  • Experimental MQTT support based on user feedback
  • Anticipates switch to version 0.9 of the WebThings gateway by implementing title support.

Version 0.1.3 added

  • New "optimize things" feature. This is a solution for things with a lot of OnOfProperty children. It basically clones them into new things. This makes the thing overview better able to function as a dashboard, and allows users to change the name for the properties. This is very useful for voice control.
  • Slightly improved support for MySensors devices
  • Attempts to use a different way of downloading requirements.

Version 1.0.0

  • Support for timeout functionality. If a node doesn't respond withith a (user definable) timeframe, the node will set to disconnected.
  • Fixed bug in HVAC support that meant not all V_types were properly supported.
  • Support for thermostat capability of WebThings Gateway
  • Support for new Lock capability has purposefully been held back for now.

Version 1.0.3

  • Attempt to make MQTT work (something I don't use myself, so anyone willing to help is welcome to)

Version 1.1.1

  • Made it compatible with WebThings 1.0 release

webthings-mysensors-adapter's People

Contributors

flatsiedatsie avatar marceloaqno avatar mickael9 avatar mrstegeman avatar supby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

webthings-mysensors-adapter's Issues

RGB Lights have no colour property setting

I made my own code for an Arduino as a RGB led strip controller based widely available examples.
Turning on/off and setting the dim level works okay, but the colour setting is unavailable.

I noticed that it seems to be an undocumented missing feature:
https://github.com/createcandle/Webthings-mysensors-adapter/blob/master/pkg/mysensors_device.py#L884

Subtype V_RGB is avaliable for Color sensor but not for RGB or RGBW lights.
If it is a known missing feature it should be documented as so, so that it does not get forgotten.

In any case I would like to understand and help, is there any limitation on Webthings to have this feature? How can I help?

Hardcoded Baud on Serial

More of a request than an issue.
Unable to modify the baud rate which is hardcoded into mysensors_adapter.
This is causing issues with serial connectivity to MCU and TTL UART - FTDI or CH340 and Linux O/S and Webthings container

Would appreciate a parameter (pull down) to specify the speed supported by pyserial

MainType 13 Power MEasuring Device needs EnergyMonitor Type

Hi again

Can you please add self._type.append('EnergyMonitor') to V_WATT and V_KWH under Power. Testing this provides a better looking icon on the Things page. I can upload an image (png) ...

Thanks

        elif new_main_type == 13:                      # Power measuring device, like power meters
            if new_sub_type == 17: # V_WATT
                self._type.append('EnergyMonitor')
                self.properties[targetPropertyID] = MySensorsProperty(
                    self,
                    targetPropertyID,
                    {
                        '@type': 'InstantaneousPowerProperty',
                        'label': new_description,
                        'type': 'number',
                        'unit': 'watt',
                        'readOnly': True,
                        'multipleOf':0.01,
                    },
                    values, new_value, new_node_id, new_child_id, new_main_type, new_sub_type)
            if new_sub_type == 18: # V_KWH
                self._type.append('EnergyMonitor')
                self.properties[targetPropertyID] = MySensorsProperty(
                    self,
                    targetPropertyID,
                    {
                        'label': new_description,
                        'type': 'number',
                        'unit': 'kwh',
                        'readOnly': True,
                        'multipleOf':0.001,
                    },
                    values, new_value, new_node_id, new_child_id, new_main_type, new_sub_type)

Permission denied on file mysensors-adapter-persistence.json

Hello,

soon after starting the gateway I've got this in logs :
2020-03-06 01:36:18.435 ERROR : mysensors-adapter: Permission denied when writing to /root/.mozilla-iot/data/mysensors-adapter/mysensors-adapter-persistence.json

Steps to reproduce :

  • Lauching "sudo webthings-gateway" (so as root)
  • Adding MySensor add-on and configure it properly
  • Connect USB gateway which is r/w capable
  • Start scanning

Same thing when manually creating the file as root or chmod it badly in 777 for testing purpose.

Thanks for your work.
Regards ,

Webthings Not Starting Mysensors Adapter Ubuntu 18.04

Hi, I have Webthings running on Ubuntu 18.04. I have it up and running and have added the Weather add-ons and Time adapter.

I'm getting an error thrown
2020-08-14 17:48:34.055 INFO : Plugin: mysensors-adapter died, code = 1 restarting after 30000
2020-08-14 17:49:04.220 ERROR : mysensors-adapter: Traceback (most recent call last):
2020-08-14 17:49:04.220 ERROR : mysensors-adapter: File "/home/clive/.mozilla-iot/addons/mysensors-adapter/main.py", line 11, in
2020-08-14 17:49:04.220 ERROR : mysensors-adapter: from pkg.mysensors_adapter import MySensorsAdapter # noqa
2020-08-14 17:49:04.221 ERROR : mysensors-adapter: File "/home/clive/.mozilla-iot/addons/mysensors-adapter/pkg/mysensors_adapter.py", line 23, in
2020-08-14 17:49:04.221 ERROR : mysensors-adapter: from gateway_addon import Adapter, Database
2020-08-14 17:49:04.221 ERROR : mysensors-adapter: ModuleNotFoundError: No module named 'gateway_addon'

I have checked and the adapter is there and is fresh in the .mozilla-iot/addons.

The Webthings was installed by hand because of a dependency issues with the .deb around nodejs version, so followed the instructions for the source/complile using npm. The gateway code is running in my Downloads folder.

Any help appreciated

Using MQTT

MySensors add-on for Mozilla WebThings Gateway v 0.1.6
MQTT server is not on the local network
I turn to him by DNS name
MQTT username: and The username for MQTT security
100% work

Which mistakes:

2019-11-06 10:24:01.377 INFO : mysensors: MQTT object init
2019-11-06 10:24:01.387 INFO : mysensors: MQTT object error: 'MQTT' object has no attribute 'username_pw_set'
2019-11-06 10:24:01.389 INFO : mysensors: subscribing to topic mygateway1-out/+/+/0/+/+
2019-11-06 10:24:01.390 INFO : mysensors: subscribing to topic mygateway1-out/+/+/3/+/+
2019-11-06 10:24:01.392 INFO : mysensors: AddonMangerProxy: recv: b'{"messageType":"unloadAdapter","data":{"adapterId":"mysensors-adapter","pluginId":"mysensors-adapter"}}'
2019-11-06 10:24:01.396 INFO : mysensors: Shutting down MySensors adapter
2019-11-06 10:24:01.398 INFO : mysensors: MySensors adapter was unable to cleanly close PyMySensors loop. This is not a problem.
2019-11-06 10:24:01.400 INFO : mysensors: AddonMangerProxy: recv: b'{"messageType":"unloadPlugin","data":{"pluginId":"mysensors-adapter"}}'
2019-11-06 10:24:04.403 INFO : Killing mysensors-adapter plugin.
2019-11-06 10:24:04.407 INFO : mysensors: Asyncio loop is not running
2019-11-06 10:24:04.409 INFO : mysensors: Bye

What's wrong?

Loop close error

2019-05-07 19:10:12.103 INFO : mysensors: AddonMangerProxy: recv: b'{"messageType":"unloadPlugin","data":{"pluginId":"mysensors-adapter"}}'
2019-05-07 19:10:15.101 INFO : Killing mysensors-adapter plugin.
2019-05-07 19:10:15.108 ERROR : mysensors: Exception in thread Thread-24:
2019-05-07 19:10:15.117 ERROR : mysensors: Traceback (most recent call last):
2019-05-07 19:10:15.120 ERROR : mysensors: File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
2019-05-07 19:10:15.122 ERROR : mysensors: self.run()
2019-05-07 19:10:15.125 ERROR : mysensors: File "/usr/lib/python3.5/threading.py", line 862, in run
2019-05-07 19:10:15.128 ERROR : mysensors: self._target(*self._args, **self._kwargs)
2019-05-07 19:10:15.131 ERROR : mysensors: File "/usr/local/lib/python3.5/dist-packages/gateway_addon/addon_manager_proxy.py", line 278, in unload_fn
2019-05-07 19:10:15.134 ERROR : mysensors: adapter.unload()
2019-05-07 19:10:15.137 ERROR : mysensors: File "/home/pi/.mozilla-iot/addons/mysensors-adapter/pkg/mysensors_adapter.py", line 100, in unload
2019-05-07 19:10:15.139 ERROR : mysensors: self.LOOP.close()
2019-05-07 19:10:15.142 ERROR : mysensors: File "/usr/lib/python3.5/asyncio/unix_events.py", line 63, in close
2019-05-07 19:10:15.145 ERROR : mysensors: super().close()
2019-05-07 19:10:15.149 ERROR : mysensors: File "/usr/lib/python3.5/asyncio/selector_events.py", line 107, in close
2019-05-07 19:10:15.151 ERROR : mysensors: raise RuntimeError("Cannot close a running event loop")
2019-05-07 19:10:15.154 ERROR : mysensors: RuntimeError: Cannot close a running event loop
2019-05-07 19:10:15.157 ERROR : mysensors:

Connect to remote mosquitto

Tried the MQTT gateway today. Had to change some lines in mysensors_adapter.py. On line 428 self.MQTT_in_Prefix should be self.MQTT_in_prefix and on line 418 self.MQTT.loop_start() should be self.MQTT.start() I think. Is this correct?

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.