Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. Implementing a new controller

Implementing a new controller

Scheduled Pinned Locked Moved Controllers
10 Posts 4 Posters 2.8k Views 6 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    user2684
    Contest Winner
    wrote on last edited by
    #1

    Hello Folks,

    I'm writing some code to make my Home Automation Suite project (https://sourceforge.net/projects/my-house/) acting as a controller. I went through old posts here on this topic, the source code of the engine, the serial protocol and API documentation as well as I've reviewed the code of other open source controllers to have an idea of what it really takes.
    I'm almost done but there are still a few things not completely clear to me. If I go through the list of functionalities that must be supported by a controller (https://www.mysensors.org/controller), I'm unsure about the following:

    • Heartbeat support: assuming this is not referring to smart sleep support which is a different item, as far as I have understood the controller is not supposed to reply to heartbeat requests (also because the controller does not have a node id). If a request is for a sensor in the network, the gateway would push it towards the radio network without even reaching the controller, if the destination is 0, the gateway itself would respond. What does this really imply?
    • Ack support: similar to the above, looks like the ack is handled by the gateway when a message comes from the radio network and it is requesting an ack.
    • Request: I've seen controllers handling requests on behalf of other sensors but apparently if e.g. sensor 1 requests something to sensor 2, the gateway would route the message to sensor 2 directly so there is no need for the controller to replay back to 1, right?

    All clear instead for the others: node id generation, OTA support and smart sleep.

    Thanks in advance!
    Dave

    1 Reply Last reply
    1
    • hekH Offline
      hekH Offline
      hek
      Admin
      wrote on last edited by
      #2

      Welcome @user2684, nice project you got going!

      1. I_HEARTBEAT_RESPONSE could be seen as a "I'm alive" message from a node. The I_HEARTBEAT_REQUEST can be used by the controller to ping (woken) sensors. The will respond with a I_HEARTBEAT_RESPONSE.
      2. Yes, ack is handled by the gateway. Controller is not involved in this communication.
      3. Yes, the controller will not even see the message if it is routed to some other sensor.
      U 1 Reply Last reply
      1
      • rmtuckerR Offline
        rmtuckerR Offline
        rmtucker
        wrote on last edited by
        #3

        Wow i like the look of this!.
        Especially the boiler sheduling and the ability to add decent graphs.
        I have been using domoticz for over a year but it is far too restricted when it comes to the gui.
        Shame i can not give it a go on my linux desktop,but never mind i have another raspi3 coming in the next few days so i will give it a whirl.

        1 Reply Last reply
        0
        • rmtuckerR Offline
          rmtuckerR Offline
          rmtucker
          wrote on last edited by
          #4

          Well i switched my sd card on my working pi and installed as per instructions.
          The script installed everything and the service.
          But i can not access the web interface??

          U 1 Reply Last reply
          0
          • hekH hek

            Welcome @user2684, nice project you got going!

            1. I_HEARTBEAT_RESPONSE could be seen as a "I'm alive" message from a node. The I_HEARTBEAT_REQUEST can be used by the controller to ping (woken) sensors. The will respond with a I_HEARTBEAT_RESPONSE.
            2. Yes, ack is handled by the gateway. Controller is not involved in this communication.
            3. Yes, the controller will not even see the message if it is routed to some other sensor.
            U Offline
            U Offline
            user2684
            Contest Winner
            wrote on last edited by
            #5

            @hek thanks for the prompt answer! Very clear, I should be close to a first working draft then. I'll update about my progress here once ready for some testing.

            1 Reply Last reply
            0
            • rmtuckerR rmtucker

              Well i switched my sd card on my working pi and installed as per instructions.
              The script installed everything and the service.
              But i can not access the web interface??

              U Offline
              U Offline
              user2684
              Contest Winner
              wrote on last edited by
              #6

              @rmtucker thanks for your feedback first of all! I'd be more than happy to look into your issue, most likely some dependency is broken despite the installation script is supposed to deploy everything needed. The log file in the "logs/myHouse.log" directory should tell the full story. Or you can run the program directly with "sudo python myHouse.py" to review the output.
              If you don't mind following up this conversation on https://sourceforge.net/p/my-house/tickets/157/ would be great, otherwise we can easily go off topic here :-)
              Thanks again

              1 Reply Last reply
              0
              • Nca78N Offline
                Nca78N Offline
                Nca78
                Hardware Contributor
                wrote on last edited by
                #7

                Very interesting project !
                I have a rpi3 too and I'll give it a try asap, like rmtucker I am a bit frustrated with the Domoticz UI...

                1 Reply Last reply
                0
                • U Offline
                  U Offline
                  user2684
                  Contest Winner
                  wrote on last edited by
                  #8

                  Hi, I've just committed a working alpha version of myHouse acting as a controller. If anyone is interested to give it a try or to review the implementation, feel free to download the snapshot from https://sourceforge.net/p/my-house/code/ci/b8d057329438c7c434f7de6b8e76dc9bdee13ca6/tree/. Of course this is a development version, it does not necessarily work great. Feel free to report any issue here or on https://sourceforge.net/p/my-house/tickets/153/.

                  The implementation is pretty simple, the gateway has to be configured in the "plugins" section (it will be part of the default configuration in the next release) and once a sensor is configured in one of the modules of myHouse, anytime a message is received from the given node_id,child_id,command,type tuple, the payload is saved as a new measure. It does support both ethernet, serial and mqtt gateways but does not support multiple gateways to run together for now. Node id generation is supported as well as smart sleep (messages are queued and delivered once the sensor is back online).

                  The sensors have to be configured before starting receiving data (this is the logic of myHouse so I couldn't change it to allow "discovering" of new sensors).

                  Full documentation of the stable version of myHouse can be found here https://sourceforge.net/p/my-house/wiki/. FYI the first time you look at the configuration, it is not really user friendly but eventually results pretty flexible. If already running it, I'd recommend creating a separate instance and using a different database to avoid interfering with the stable version.

                  The global configuration looks like the following:

                  	"mysensors": {
                  		"enabled": true,
                  		"gateway_type": "ethernet",
                  		"gateways": {
                  			"serial": {
                  				"port": "/dev/ttyAMA0",
                  				"baud": 57600
                  			},
                  			"ethernet": {
                  				"hostname": "localhost",
                  				"port": 5003
                  			},
                  			"mqtt": {
                  				"hostname": "localhost",
                  				"port": 1883,
                  				"subscribe_topic_prefix": "mysensors-out",
                  				"publish_topic_prefix": "mysensors-in"
                  			}
                  		}
                  	}
                  

                  A temperature sensor using the plugin would look like the following:

                          {
                  		  "module_id": "test",
                            "group_id": "temperature",
                            "sensor_id": "test",
                  		  "enabled": true,
                            "display_name": {
                  			"en": "Temperature"
                  			},
                            "plugin": {
                              "plugin_name": "mysensors",
                  			"node_id": 254,
                              "child_id": 1,
                  			"command": "SET",
                  			"type": "V_TEMP"
                            },
                            "format": "temperature"
                          }
                  

                  Thanks

                  rmtuckerR 1 Reply Last reply
                  2
                  • U user2684

                    Hi, I've just committed a working alpha version of myHouse acting as a controller. If anyone is interested to give it a try or to review the implementation, feel free to download the snapshot from https://sourceforge.net/p/my-house/code/ci/b8d057329438c7c434f7de6b8e76dc9bdee13ca6/tree/. Of course this is a development version, it does not necessarily work great. Feel free to report any issue here or on https://sourceforge.net/p/my-house/tickets/153/.

                    The implementation is pretty simple, the gateway has to be configured in the "plugins" section (it will be part of the default configuration in the next release) and once a sensor is configured in one of the modules of myHouse, anytime a message is received from the given node_id,child_id,command,type tuple, the payload is saved as a new measure. It does support both ethernet, serial and mqtt gateways but does not support multiple gateways to run together for now. Node id generation is supported as well as smart sleep (messages are queued and delivered once the sensor is back online).

                    The sensors have to be configured before starting receiving data (this is the logic of myHouse so I couldn't change it to allow "discovering" of new sensors).

                    Full documentation of the stable version of myHouse can be found here https://sourceforge.net/p/my-house/wiki/. FYI the first time you look at the configuration, it is not really user friendly but eventually results pretty flexible. If already running it, I'd recommend creating a separate instance and using a different database to avoid interfering with the stable version.

                    The global configuration looks like the following:

                    	"mysensors": {
                    		"enabled": true,
                    		"gateway_type": "ethernet",
                    		"gateways": {
                    			"serial": {
                    				"port": "/dev/ttyAMA0",
                    				"baud": 57600
                    			},
                    			"ethernet": {
                    				"hostname": "localhost",
                    				"port": 5003
                    			},
                    			"mqtt": {
                    				"hostname": "localhost",
                    				"port": 1883,
                    				"subscribe_topic_prefix": "mysensors-out",
                    				"publish_topic_prefix": "mysensors-in"
                    			}
                    		}
                    	}
                    

                    A temperature sensor using the plugin would look like the following:

                            {
                    		  "module_id": "test",
                              "group_id": "temperature",
                              "sensor_id": "test",
                    		  "enabled": true,
                              "display_name": {
                    			"en": "Temperature"
                    			},
                              "plugin": {
                                "plugin_name": "mysensors",
                    			"node_id": 254,
                                "child_id": 1,
                    			"command": "SET",
                    			"type": "V_TEMP"
                              },
                              "format": "temperature"
                            }
                    

                    Thanks

                    rmtuckerR Offline
                    rmtuckerR Offline
                    rmtucker
                    wrote on last edited by
                    #9

                    @user2684 said in Implementing a new controller:

                    Node id generation is supported as well as smart sleep (messages are queued and delivered once the sensor is back online).

                    Just wondering how that would work without auto discovery?
                    So the controller assigns a node id but how would you find out what node id had been assigned so you could enter it like above?

                    U 1 Reply Last reply
                    0
                    • rmtuckerR rmtucker

                      @user2684 said in Implementing a new controller:

                      Node id generation is supported as well as smart sleep (messages are queued and delivered once the sensor is back online).

                      Just wondering how that would work without auto discovery?
                      So the controller assigns a node id but how would you find out what node id had been assigned so you could enter it like above?

                      U Offline
                      U Offline
                      user2684
                      Contest Winner
                      wrote on last edited by
                      #10

                      The controller can assign a sensor the node id and since every message the sensor sends back to the controller is logged, you can get the id from the logs and then configure you sensor in myHouse. Not ideal I know but would allow a pretty fast start and this is a one time only task.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      22

                      Online

                      11.7k

                      Users

                      11.2k

                      Topics

                      113.1k

                      Posts


                      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • MySensors
                      • OpenHardware.io
                      • Categories
                      • Recent
                      • Tags
                      • Popular