SmartThings Community

[RELEASE] OmniThing v0.8.2 - ESP8266/ESP32/RaspberryPi/Linux/Windows - A cross-platform successor to ST_Anything - Web-based Configuration Tool

Okay, so I am having trouble getting the switch device to work. I’m not clear on what I have to have for triggers or subscriptions for this device. An example would be extremely helpful. The contact sensor i have is working perfectly.

{
    "NetworkReceiver": {
        "type": "NetworkReceiverHttpLib",
        "port": 8090
    },
    "NetworkSender": {
        "type": "NetworkSenderHttpLib",
        "ip": "192.168.1.12",
        "port": 39501
    },
    "CompositePeriphs": [],
    "Devices": [
        {
            "triggers": [],
            "subscriptions": [
                {
                    "source": "Power Monitor",
                    "event": "changed",
                    "command": "poll"
                }
            ],
            "type": "ContactSensor",
            "name": "Power Monitor",
            "input": {
                "type": "DigitalInputPinRaspberryPi",
                "pin": 21,
                "invert": true,
                "pinMode": "Pullup"
            },
            "invert": false,
            "constantPoll": true
        },
        {
            "triggers": [],
            "subscriptions": [
                {
                    "source": "Hub Reboot",
                    "event": "changed",
                    "command": "toggle"
                }
            ],
            "type": "Switch",
            "name": "Hub Reboot",
            "output": {
                "type": "DigitalOutputPinRaspberryPi",
                "initial": false,
                "invert": false,
                "pin": 20
            },
            "invert": false,
            "initial": false,
            "input": {},
            "ignoreRedundant": false
        }
    ]
}

I am issuing commands to the device but I don’t actually see the state of the device change. I also tried this:

{
    "triggers": [
        {
            "interval": 60000,
            "offset": 1,
            "command": "poll"
        }
    ],
    "subscriptions": [
        {
            "source": "Hub Reboot",
            "event": "changed",
            "command": "toggle"
        },
        {
            "source": "Hub Reboot",
            "event": "on",
            "command": "poll"
        },
        {
            "source": "Hub Reboot",
            "event": "off",
            "command": "poll"
        }
    ],
    "type": "Switch",
    "name": "Hub Reboot",
    "output": {
        "type": "DigitalOutputPinRaspberryPi",
        "initial": false,
        "invert": false,
        "pin": 20
    },
    "invert": false,
    "initial": false,
    "input": {},
    "ignoreRedundant": false
}

]
}

That didn’t work either. I’ve been trying different combinations for a couple days now and just can’t seem to get it to work.

I just released version 0.6.0, and it adds the InputDebouncer, which is a new InputBool type. It can be used to ignore input changes for a configurable debounce period (in milliseconds). I believe the json below will achieve what you’re wanting to do with your sensor (might have to adjust the debounce duration or which edges to trigger the debounce on).

{
            "triggers": [
                {
                    "interval": 15000,
                    "offset": 1000,
                    "command": "poll"
                }
            ],
            "subscriptions": [],
            "type": "MotionSensor",
            "name": "generator_running",
            "input": {
                "type": "InputDebouncer",
                "input": {
                    "type": "DigitalInputPinRaspberryPi",
                    "pin": 6,
                    "invert": false,
                    "pinMode": "Normal"
                },
                "mode": "Falling",
                "duration": 60000
            },
            "invert": true,
            "constantPoll": true
        }

Hi Gene,

OmniThing allows SmartThings to control your RaspberryPi. That can include running scripts based on a SmartThings switch turning on or off. It can also control the pi’s gpios. Do you have a particular use case in mind?

It’s designed to give you a lot of control over its behavior.

I would recommend you remove all of your subscriptions entries. They are for doing local automation with OmniThing, which I don’t think you’re trying to do.

For example, the Hub Reboot subscription is telling the switch to toggle its own state every time its state changes. This is probably resulting in an infinite loop of the switch toggling itself as fast as it can.

Try eliminating all the subscriptions and leaving in the 60 second trigger you tried. I have plans to add proper refresh functionality that should eliminate the need for adding “poll” triggers on switches, but for now it’s necessary to ensure that SmartThings will create the child device if it doesn’t already exist.

I did that…and it still wouldn’t turn on. These are the logs:

[dev:1221](http://192.168.1.12/logs#dev1221)2018-12-31 08:43:40.262 pm [debug](http://192.168.1.12/device/edit/1221)received body: ok

[dev:1221](http://192.168.1.12/logs#dev1221)2018-12-31 08:43:40.176 pm [debug](http://192.168.1.12/device/edit/1221)Using ip: 192.168.1.36 and port: 8090 for device: 1221

[dev:1221](http://192.168.1.12/logs#dev1221)2018-12-31 08:43:40.174 pm [debug](http://192.168.1.12/device/edit/1221)Executing 'sendEthernet' {"name":"Hub Reboot","cmd":"on"}

Here’s the config:

    "subscriptions": [],
    "type": "Switch",
    "name": "Hub Reboot",
    "output": {
        "type": "DigitalOutputPinRaspberryPi",
        "initial": false,
        "invert": false,
        "pin": 20
    },
    "invert": false,
    "initial": false,
    "input": {},
    "ignoreRedundant": false

When you say it doesn’t change state, are you talking about the Pi’s gpio pin, the device in ST/Hubitat, or both? That might help narrow down what’s going on.

The web logs at least confirm that it’s sending the command, and your config looks fine to me, so it would be helpful to figure out if OmniThing ever receives the json from the hub.

A quick sanity check would be double checking the pi’s IP is still 192.168.1.36. Is this the same pi that was running OmniThing with a virtual MAC address? If it is, make sure that the IP is the one associated with the virtual interface (specified in /etc/network/interfaces.d/omnithing). If it’s the IP of the Pi’s normal interface, OmniThing will never receive those packets.

If that checks out, can you check the omnithing logs on the pi? If you ssh to the pi and run tail -F /opt/omnithing/logs/omnithing.log you can monitor the log in real time. Check if when you turn the switch on/off if OmniThing ever prints that it received it.

GOT IT!!! It doesn’t like the space in the device name!!! This is what the logs from the Pi said:

Received json: {"name":"Hub Reboot","cmd":"on"}
No device found with name=Hub

Once I put in something with no space it worked perfectly.

Thanks for getting back to me. There are a couple instances I’d like to do if possible. One is to control a GPIO pin powering a cooling fan where I could tie it to a Harmony activity using webCoRE. If watch tv is on then turn fan off. Another thing I’d love to be able to do is run scripts. I’ve been wanting to connect one Pi to a smart plug but don’t want to just cut power to the pi when turning plug off so I was thinking of running shutdown command first.

Thanks! I’ve installed the updated version and will test it out tomorrow.
Dave

Glad you got it working. It looks like I have a bug to track down with the name parsing if it’s throwing out names with spaces.

Not for contact sensors…only for switches it seems. It is truncating them.

I haven’t forgotten about this, but unfortunately my generator has gone off-line (and is far away), so I can start/stop to generate some vibration. Will check back in once I can do some further testing…

Ok, i decided to try this out, using a Pi and DS18B20 temp sensor.

I know the sensor works on the pi:

pi@raspberrypi1:/sys/bus/w1/devices/28-020292467633 $ cat w1_slave
74 01 55 05 7f 7e 81 66 f0 : crc=f0 YES
74 01 55 05 7f 7e 81 66 f0 t=23250

in smartthings, its saying -1 degrees

my config:
{
“NetworkReceiver”: {
“type”: “NetworkReceiverHttpLib”,
“port”: 8090
},
“NetworkSender”: {
“type”: “NetworkSenderHttpLib”,
“ip”: “192.168.1.100”,
“port”: 39500
},
“CompositePeriphs”: [
{
“type”: “DhtReader”,
“name”: “DS18B20”,
“pin”: 4,
“pullup”: false,
“dht11”: false
}
],
“Devices”: [
{
“triggers”: [
{
“interval”: 15000,
“offset”: 0,
“command”: “poll”
}
],
“subscriptions”: ,
“type”: “TemperatureMeasurement”,
“name”: “Rasp1Temp”,
“input”: {
“type”: “InputFloatRef”,
“compositeName”: “DS18B20”,
“paramName”: “temperature”
}
}
]
}
What am I missing here? Thanks
-Bill

Edit: omnithing logs show :

ERROR: error reading temp/humidity (-2)
ERROR: Failed to get float=temperature from DS18B20
ERROR: float value too many digits

OK i can get contact switches working with no issue with raspi. Still unable to get the temp working as stated above. I’ve never heard of nodemcu before looking at omnithing, looked interesting so i figured id give it a shot and ordered a couple. However using the generator, when attempting to compile the sketch i’m recieving the error " ‘virtual bool omni::DigitalInputPinArduino::configure()’ cannot be overloaded"

Also regarding raspi, dht22 works, however device handler will not convert to Fahrenheit from Celsius. The ds18b20 probe doesn’t work, need to get omnithing to trim the float value…

Does anyone have a full walkthrough guide or video on how to set this up? I’ve got everything installed but not sure how to use the web configuration tool. New to Linux so that doesn’t help.

Sorry, looks like I introduced a couple arduino compilation errors for the last release. If you download the sketch again from the site, it should compile correctly.

As for the ds18b20, OmniThing does not currently support it. The error about the float’s length is likely due to it getting garbage data, since it’s assuming it’s communicating with a DHT22.

I’m planning on adding an input type that gets a float value from a script’s output. Since it looks like you already have the sensor working on the pi using an existing driver, that may be the easiest way to get the ds18b20’s value into OmniThing. Either that or we add support for the sensor directly to OmniThing. Then it would be usable on Arduino platforms as well.

1 Like

To clarify, are you able to access the tool and just need to know how to configure it?

Correct. I can access config tool just not sure what to do when I’m there.

Either way would be great. Adding DS18B20 support would make for easier adding of sensors, however there would be more to it than the DHT22 since you can add as many as you want in parallel. The script option opens the door for many options outside of this particular probe, and could easily write script for multiple in parallel, let alone other items outside of temp sensors.

edit: did you get a chance to look at the DH? mine is not converting from C to F… I setup a virtual thermometer to convert with webcore, but it would be nice to have it done without the extra virtual device…

what are you trying to do?