Nymea setup in RV - Video, super cool


Doesn’t have the switches integrated in it yet, but still very cool guys.

Hey John, very very cool.
I think especially for the connection controls we could get out some more by creating a dedicated plugin… When I’ll find some time I’ll template something for you.

On the name nymea, noticed this in your previous video already, you seem to lose the e :blush:.
Try hitting the play button on english here https://translate.google.de/?sl=de&tl=en&text=nymea&op=translate
We put a tad less emphasis on the y than the google voice, but it’s quite close.

Again, thanks for sharing.

Hey John,

Here’s an example plugin that would do all that connection management in one thing. You’d need 2 files:


    "id": "4e860765-08dd-4e77-af8c-af7a8a448cb4",
    "name": "rvConnectivity",
    "displayName": "RV connectivity",
    "vendors": [
            "id": "c36c6405-961a-4626-9db8-1011a72b79b0",
            "name": "dunarri",
            "displayName": "Dunarri",
            "thingClasses": [
                    "id": "f4a460d4-ab07-4801-83e9-988f80bec3c6",
                    "name": "rvConnectivity",
                    "displayName": "RV connectivity",
                    "createMethods": ["user"],
                    "interfaces": ["wirelessconnectable", "power"],
                    "stateTypes": [
                            "id": "dae59b58-96b4-47d0-b483-2b06377f259e",
                            "name": "power",
                            "displayName": "Enabled",
                            "displayNameEvent": "Enabled/disabled",
                            "displayNameAction": "Enable/disable",
                            "type": "bool",
                            "defaultValue": false,
                            "writable": true
                            "id": "7fd40db6-bede-4204-b539-424c19873e03",
                            "name": "connected",
                            "displayName": "Connected",
                            "displayNameEvent": "Connected/disconnected",
                            "type": "bool",
                            "defaultValue": false,
                            "cached": false
                            "id": "f3b8e4d7-c6ff-41e9-9860-5070f2ae94f8",
                            "name": "signalStrength",
                            "displayName": "Signal strength",
                            "displayNameEvent": "Signal strength changed",
                            "type": "uint",
                            "defaultValue": 0,
                            "minValue": 0,
                            "maxValue": 100,
                            "unit": "Percentage"


import nymea
import os
import subprocess
import time

# Setting up a loop that polls the signal strength every 5 seconds...
loopRunning = False

# Init is called when nymea starts up... We just start the loop here
def init():
    logger.log("RV connectivity init")
    global loopRunning
    loopRunning = True

    while loopRunning:
        for thing in myThings():
            # Call a command that just prints the signal strength, in this example we just do "echo 75"
            commandOutput = call_output("echo", "75").decode("UTF-8")
            logger.log("output: %s" % commandOutput)
            thing.setStateValue(rvConnectivitySignalStrengthStateTypeId, int(commandOutput.strip()))

# When nymea stops, we need to stop our loop
def deinit():
    global loopRunning
    loopRunning = False

# When the user adds a new rv connectivity thing. Nothing to be done here, we just need to finish() the setup.
def setupThing(info):
    logger.log("RV setup")

# When the user flips a switch
def executeAction(info):
    logger.log("RV action")
    if info.actionTypeId == rvConnectivityPowerActionTypeId:
        if info.paramValue(rvConnectivityPowerActionPowerParamTypeId) == True:
            # This example would call "echo command to set connection online goes here..."
            # and parse the output for the word "online". If found, it assumes it succeeded and sets the thing to connected
            commandOutput = call_output("echo", "command to set connection to online goes here...").decode("UTF-8")
            if "online" in commandOutput:
                info.thing.setStateValue(rvConnectivityPowerStateTypeId, True)
                info.thing.setStateValue(rvConnectivityConnectedStateTypeId, True)
                info.finish(nymea.ThingErrorHardwareFailure, "Error establishing connection")

            commandOutput = call_output("echo", "command to set connection to offline goes here...").decode("UTF-8")
            if "offline" in commandOutput:
                info.thing.setStateValue(rvConnectivityPowerStateTypeId, False)
                info.thing.setStateValue(rvConnectivityConnectedStateTypeId, False)
                info.finish(nymea.ThingErrorHardwareFailure, "Error tearing down connection")

# Just some helper functions to call bash commands, one that just fires and forget
def call(*args, env=os.environ):
    return subprocess.check_call(list(args), env=env)

# and one that reads back the ouput of the command and returns it to the caller
def call_output(*args, env=os.environ):
    return subprocess.check_output(list(args), env=env)

Place them in /usr/lib/arm-linux-gnueabihf/nymea/plugins/rvconnectivity/ then restart nymea. You’ll be able to set up a new thing called “RV Connectivity” which would look like this:


You’d need to adjust the plugin code to call commands that establish the connection etc. I’ve added comments to the code, read through them and adjust accordingly.

In nymea’s debug webinterface you’ll find a new switch for this plugin to enable logging of the messages printed with logger.log() in the plugin code.

For additional info, check out the docs on nymea.io

Awesome, that gives me a base to work from to get it doing what i need. You may have misunderstodd slightly what the things on the screen do:

“LTE Uplink” - Runs a command i have that turns on the LTE interface in the router via api call.

“WIFI Uplink” - Runs a command i have that turns on the external wifi interface in the router via api call.

“Internet Connectivity” - Watches a MQTT topic thats changes based on connectivity. I set the topic by having a little daemon script run every 5 seconds and try to ping…from that it sets a MQTT topic to “yes” or “no”. This then of course updates the indicator of that thing. The “switch” of the thing does nothing.

The signal strength also comes from a small script daemon i have running and does an api call to the router to check the strength every few seconds. Same deal as above, sets a MQTT topic, and i read that info nymea.

But i think i now see how i can mod this a bit to get what i want.

I added the above files to the dir, and now i see the topic in the debug web interface, but when i go to configure things and hit the + i cant find it there. Must have missed somthing.



Right, this was mostly meant as an example so you can adjust it to your needs.

Turn on logs for “ThingManager” and watch the output of nymead during startup. It would print stuff related to you your plugin if there’s an issue somewhere. Perhaps easist to stop the service and run nymead manually as described here in the docs:

Very good idea. Running it manually i found the issue…i missed the first “import” in the code =)…

This example is good for many people looking to get a plugin working but not quite understanding the docs. Its very well explained in this thread, so you could pop this in and work on moding it for your use.