SmartThings Community

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


#16

Got a slight problem. The Device Network it is trying to pull is the RPi’s MAC address. Unfortunately, I also use that Pi for Cast-Web-Api, which also uses the MAC address for the Device Network ID in ST. Any way we can set that to the MAC plus OT (for omni thing) or something similar?


(Dan) #17

Not that I know of. ST uses the MAC address of the LAN attached MCU to look up and find the corresponding ST Device with the matching DeviceNetworkID. This is done outside of any custom code.

I believe it is one ST Device per LAN attached MCU.

Just grab a $10 RPi ZeroW to run each application! :wink:


(Daniel) #18

I believe this is possible on a Raspberry Pi, but it will require creating a virtual network interface. Basically, you can create a virtual interface that you can give any fake MAC address you want. Then you can have it use the actual Ethernet interface behind the scenes. I would have to add support to the NetworkSender and NetworkReceiver to allow specifying which interface to use, but I don’t think that should be too difficult. I can take a closer look at it tonight.


#19

I guess I could… Just trying to eliminate as many failure points as possible. More devices = more chances for something to go wrong.


#20

Thanks for taking a look.


(Daniel) #21

I have managed to get OmniThing working on a raspberry pi using a virtual ethernet interface.

Create a new file called /etc/network/interfaces.d/omnithing

In that file, paste the text below with a few modifications:

auto eth_omni
iface eth_omni inet static
  address 192.168.1.54/24
  hwaddress ether ba:4d:09:46:57:98
  pre-up ip link add eth_omni link eth0 type macvlan
  post-down ip link del eth_omni link eth0 type macvlan
  up ip netns add omnithing && ip link set eth_omni netns omnithing && ip netns exec omnithing ip addr add 192.168.1.54/24 dev eth_omni && ip netns exec omnithing ip link set eth_omni up
  down ip netns del omnithing

Replace “ba:4d:09:46:57:98” with whatever made up mac address you want for the virtual interface.

Replace both instances of “192.168.1.54/24” with whatever static IP you want to assign to the virtual interface (this should be a valid ip on your LAN’s subnet which isn’t already in use; NOTE: this should NOT be the same as the pi’s eth0 ip).

Now, edit the OmniThing script found at /opt/omnithing/omnithing.sh
Replace this line:

./OmniThing config.json >> logs/omnithing.log 2>&1

With this:

ip netns exec omnithing ./OmniThing config.json >> logs/omnithing.log 2>&1

Now, run this command to ensure new versions of the omnithing package will not overwrite your edited omnithing.sh:

sudo dpkg-divert --divert /opt/omnithing/omnithing.sh.new /opt/omnithing/omnithing.sh

If you already had OmniThing installed on your pi, be sure to update it before rebooting. I just released a fix for a nasty bug associated with the CommandExecuter:

sudo apt-get update && sudo apt-get upgrade

Now feel free to reboot, and OmniThing should use the virtual interface for now on.

When configuring OmniThing in the SmartThings app, be sure to use the ip and mac you set in the interfaces file above, not your pi’s eth0 ip and mac.

If you ever want to see information about your virtual interface, run:

sudo ip netns exec omnithing ip addr

Mqtt-bridge and cast-web device network id
#22

I will give that a shot. Thank you,!!!


#23

Great, thanks! I’ll try this and report back. I use pm2, so will use that to start it and monitor the state.


#24

So, after I do this, would I also access the web configuration with the new IP address or the old IP address?


(Daniel) #25

You’d use the old IP. The nodejs server is still running on the eth0 interface.

Edit: though if you wanted to you could make it run using the new IP by similarly editing it’s startup script.


#26

Okay…I’m not sure what I’m doing wrong. It created a child device but it doesn’t seem to be actually changing the state of my GPIO pin. Here’s the JSON config. Any idea what I’m doing wrong?

{
    "NetworkReceiver": {
        "type": "NetworkReceiverHttpLib",
        "port": 8090
    },
    "NetworkSender": {
        "type": "NetworkSenderHttpLib",
        "ip": "192.168.1.24",
        "port": 39500
    },
    "CompositePeriphs": [],
    "Devices": [
        {
            "triggers": [
                {
                    "interval": 0,
                    "offset": 0,
                    "command": "poll"
                }
            ],
            "subscriptions": [
                {
                    "source": "Switch",
                    "event": "changed",
                    "command": "poll"
                }
            ],
            "type": "Switch",
            "name": "Switch",
            "output": {
                "type": "DigitalOutputPinRaspberryPi",
                "initial": false,
                "invert": false,
                "pin": 16
            },
            "invert": false,
            "initial": false,
            "input": {},
            "ignoreRedundant": false
        }
    ]
}

(Daniel) #27

I would change the poll interval for the switch to at least 5000 ms. As it is, it’s likely trying to constantly send packets to the hub.

After that if things aren’t working, run “tail -F /opt/omnithing/logs/omnithing.log” to watch the log. Try turning the switch on and off in the smartthings app, and verify that the log outputs that it’s receiving json messages from ST.

Since the ST child device has been created, that verifies that Omnithing to hub communications are working. It’s possible that something is up with SmartThings to Omnithing communications.


#28

So, I tried deleting the parent device and recreating it, thinking that was the problem. I also made the changes to the config like your recommended for the polling interval. Now, I get two devices in ST and neither of them does anything other than “turning on”.

So, I deleted the parent again and then created a new one. And I still only get Turning On or Turning Off.

Is that the only change you would recommend for the JSON config? I am totally just guessing at all of it so any recommendation you would have would be appreciated.


(Daniel) #29

I think the json is fine. Have you tried looking at the Omnithing log? That’s the best way to figure out if it’s receiving the commands from ST.


#30

It does not appear to be. here’s the updated JSON file"

{
    "NetworkReceiver": {
        "type": "NetworkReceiverHttpLib",
        "port": 8090
    },
    "NetworkSender": {
        "type": "NetworkSenderHttpLib",
        "ip": "192.168.1.24",
        "port": 39500
    },
    "CompositePeriphs": [],
    "Devices": [
        {
            "triggers": [
                {
                    "interval": 500,
                    "offset": 0,
                    "command": "poll"
                }
            ],
            "subscriptions": [
                {
                    "source": "Switch",
                    "event": "changed",
                    "command": "poll"
                }
            ],
            "type": "Switch",
            "name": "Switch",
            "output": {
                "type": "DigitalOutputPinRaspberryPi",
                "initial": false,
                "invert": false,
                "pin": 16
            },
            "invert": false,
            "initial": false,
            "input": {},
            "ignoreRedundant": false
        }
    ]
}

and here’s what I see in the omnithing log:

Sending json: {"updates": [{"name": "Switch", "type": "Switch", "switch": "off"}]}
Return value: 202
Poll triggered for Switch Switch
{"name": "Switch", "type": "Switch", "switch": "off"}

Sending json: {"updates": [{"name": "Switch", "type": "Switch", "switch": "off"}]}
Return value: 202
Poll triggered for Switch Switch
{"name": "Switch", "type": "Switch", "switch": "off"}

Sending json: {"updates": [{"name": "Switch", "type": "Switch", "switch": "off"}]}
Return value: 202
Poll triggered for Switch Switch
{"name": "Switch", "type": "Switch", "switch": "off"}

This is what i’m seeing in LiveLogging…it also appears to be inundating my hub with status messages.

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:24 PM: debug sending event: name=switch value=off

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:24 PM: debug parsing [name:Switch, switch:off, type:Switch]

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:23 PM: debug sending event: name=switch value=off

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:23 PM: debug parsing [name:Switch, switch:off, type:Switch]

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:21 PM: debug sending event: name=switch value=off

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:21 PM: debug parsing [name:Switch, switch:off, type:Switch]

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:21 PM: debug sending event: name=switch value=off

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:21 PM: debug parsing [name:Switch, switch:off, type:Switch]

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:18 PM: debug sending event: name=switch value=off

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:18 PM: debug parsing [name:Switch, switch:off, type:Switch]

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:17 PM: debug sending event: name=switch value=off

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:17 PM: debug parsing [name:Switch, switch:off, type:Switch]

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:14 PM: debug sending event: name=switch value=off

[648d053d-9938-43db-a505-a46fc7d990b6](https://graph.api.smartthings.com/ide/logs#648d053d-9938-43db-a505-a46fc7d990b6) 5:40:14 PM: debug parsing [name:Switch, switch:off, type:Switch]

Live logging for the parent device:

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:36 PM: debug child with name=Switch exists already.

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:36 PM: debug Searching for child device with network id: BA4D09465798_Switch

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:36 PM: debug parsing updates array

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:36 PM: debug [updates:[[name:Switch, switch:off, type:Switch]]]

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:36 PM: debug received body:
{"updates": [{"name": "Switch", "type": "Switch", "switch": "off"}]}

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:34 PM: debug child with name=Switch exists already.

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:34 PM: debug Searching for child device with network id: BA4D09465798_Switch

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:34 PM: debug parsing updates array

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:34 PM: debug [updates:[[name:Switch, switch:off, type:Switch]]]

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:34 PM: debug received body:
{"updates": [{"name": "Switch", "type": "Switch", "switch": "off"}]}

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:32 PM: debug child with name=Switch exists already.

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:32 PM: debug Searching for child device with network id: BA4D09465798_Switch

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:32 PM: debug parsing updates array

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:32 PM: debug [updates:[[name:Switch, switch:off, type:Switch]]]

[153da20b-99b2-48c9-a1c3-e35531022e69](https://graph.api.smartthings.com/ide/logs#153da20b-99b2-48c9-a1c3-e35531022e69) 5:41:32 PM: debug received body:
{"updates": [{"name": "Switch", "type": "Switch", "switch": "off"}]}

(Daniel) #31

You’re missing a zero on that poll interval. It should be 5000, not 500 (hence the constant message spamming to the hub every half second).

Just to double check, go back into the omnithing parent settings in the SmartThings app, and make sure you specified 8090 as the port and whatever IP you put in that interfaces file for the IP.

Also can you show me the output of sudo ip netns exec omnithing ip addr ?

When you toggle the switch on/off, do you get log output in the parent device handler similar to this?

ebcad37e-a380-43fd-9702-9c7d921da979  5:55:08 PM: debug Using ip: 192.168.1.54 and port: 8090 for 
device: ebcad37e-a380-43fd-9702-9c7d921da979
ebcad37e-a380-43fd-9702-9c7d921da979  5:55:08 PM: debug Executing 'sendEthernet' 
{"name":"executerTest","cmd":"push"}

#32

ARGH!!! I was wondering why you had me setting it for only 500 ms. Never occurred to me to double check i was reading it write. DUH! Thank you so much. I’ll give it another shot later tonight.

Okay…here’s something even weirder. I just checked my router’s IP address table and the virtual network device, the one I assigned IP address .111 to, has an IP address of .54! And that MAC doesn’t appear anywhere in my reserved addresses table. I just checked /etc/network/interfaces.d/omnithing and it is set to .111. So, where is it getting the 54 from?!? So odd.

I switched it to 54 in ST and it worked!!! So, hey, not gonna argue. It’s working.


(Daniel) #33

Oh yeah that’s because it’s the static address being set in that interfaces file. The virtual interface isn’t set up to use DHCP as it’s currently configured. I’m glad you got it working!


#34

Yeah, but i had mine set to .111 in the interfaces file. So, why would it use .54? And nope, definitely not working. Getting too frustrated to keep working on it today. Maybe some other day.


(Daniel) #35

It’s actually in 2 places in the interfaces file. I’d make sure you changed it in both, since my example has it as 54.

The value toward the top gets overwritten by the value below. It has to reset the IP after the network namespace is created.