DanielOgorchock / OmniThing

OmniThing turns your ESP32, ESP8266, Raspberry Pi, Linux Computer, or Windows Computer into a SmartThings composite Device. It is being developed as a cross-platform successor to ST_Anything.
GNU General Public License v3.0
64 stars 16 forks source link

No new devices in ST #12

Closed sfalvey closed 5 years ago

sfalvey commented 5 years ago

I cant figure out what I'm doing wrong here. Everything seems to be configured correctly but I get no new devices registered in ST except for the one I have manually put in.

Here is the config

{
    "NetworkReceiver": {
        "type": "NetworkReceiverHttpLib",
        "port": 3838
    },
    "NetworkSender": {
        "type": "NetworkSenderHttpLib",
        "ip": "192.168.20.112",
        "port": 39500
    },
    "CompositePeriphs": [],
    "Devices": [
        {
            "triggers": [],
            "subscriptions": [],
            "type": "Switch",
            "name": "Door 0",
            "output": {
                "type": "CommandExecuterSwitch",
                "commandOn": "/home/pi/tea.sh",
                "commandOff": "/home/pi/tea.sh",
                "multithread": true
            },
            "invert": false,
            "initial": false,
            "input": {
                "type": "CommandReturnCode",
                "command": "/home/pi/door.py 0 status"
            },
            "ignoreRedundant": false
        },
        {
            "triggers": [],
            "subscriptions": [],
            "type": "Switch",
            "name": "Door 1",
            "output": {
                "type": "CommandExecuterSwitch",
                "commandOn": "/home/pi/coffee.sh",
                "commandOff": "/home/pi/coffee.sh",
                "multithread": true
            },
            "invert": false,
            "initial": false,
            "input": {
                "type": "CommandReturnCode",
                "command": "/home/pi/door.py 1 status"
            },
            "ignoreRedundant": false
        },
        {
            "triggers": [],
            "subscriptions": [],
            "type": "Switch",
            "name": "Door 2",
            "output": {
                "type": "CommandExecuterSwitch",
                "commandOn": "/home/pi/olay.sh",
                "commandOff": "/home/pi/olay.sh",
                "multithread": true
            },
            "invert": false,
            "initial": false,
            "input": {
                "type": "CommandReturnCode",
                "command": "/home/pi/door.py 2 status"
            },
            "ignoreRedundant": false
        }
    ]
}

In ST I have

Name | Garage Doors
Label | Garage Doors
Type | omni_parent
Version | Self-Published
Device Network Id | 00E04C81B398
Status | ACTIVE
Hub | Home Hub
Last Activity At | 2019-07-03 2:13 PM AEST
Date Created | 2019-07-03 2:13 PM AEST
Last Updated | 2019-07-03 2:42 PM AEST
Data | No data found for device
Current States | No states found
Preferences                                                  (edit) | Name                                 Type                                 Value                                                                                                                                                                                          ip                                     text                                     192.168.20.100                                                                                                                                    mac                                     text                                     00e04c81b398                                                                                                                                    port                                     text                                     3838 
Execution Location | Cloud

I can see in live logging that the refresh signal gets received but nothing more happens than that.

Also when omnithings starts it seems to want to run the on/off commands, which since its controlling my garage doors seems a bit odd. Here is the latest log

Initialized pigpio
Attempting to open configuration file: config.json
Parsing Json Config:
{
    "NetworkReceiver": {
        "type": "NetworkReceiverHttpLib",
        "port": 3838
    },
    "NetworkSender": {
        "type": "NetworkSenderHttpLib",
        "ip": "192.168.20.112",
        "port": 39500
    },
    "CompositePeriphs": [],
    "Devices": [
        {
            "triggers": [],
            "subscriptions": [],
            "type": "Switch",
            "name": "Door 0",
            "output": {
                "type": "CommandExecuterSwitch",
                "commandOn": "/home/pi/tea.sh",
                "commandOff": "/home/pi/tea.sh",
                "multithread": true
            },
            "invert": false,
            "initial": false,
            "input": {
                "type": "CommandReturnCode",
                "command": "/home/pi/door.py 0 status"
            },
            "ignoreRedundant": false
        },
        {
            "triggers": [],
            "subscriptions": [],
            "type": "Switch",
            "name": "Door 1",
            "output": {
                "type": "CommandExecuterSwitch",
                "commandOn": "/home/pi/coffee.sh",
                "commandOff": "/home/pi/coffee.sh",
                "multithread": true
            },
            "invert": false,
            "initial": false,
            "input": {
                "type": "CommandReturnCode",
                "command": "/home/pi/door.py 1 status"
            },
            "ignoreRedundant": false
        },
        {
            "triggers": [],
            "subscriptions": [],
            "type": "Switch",
            "name": "Door 2",
            "output": {
                "type": "CommandExecuterSwitch",
                "commandOn": "/home/pi/olay.sh",
                "commandOff": "/home/pi/olay.sh",
                "multithread": true
            },
            "invert": false,
            "initial": false,
            "input": {
                "type": "CommandReturnCode",
                "command": "/home/pi/door.py 2 status"
            },
            "ignoreRedundant": false
        }
    ]
}

Found NetworkReceiver entry
Found configuration
port=3838
Successfully created new {
        "type": "NetworkReceiverHttpLib",
        "port": 3838
    }
Found NetworkSender entry
Found configuration
ip=192.168.20.112 port=39500
Successfully created new {
        "type": "NetworkSenderHttpLib",
        "ip": "192.168.20.112",
        "port": 39500
    }
Optional input provided
Switch: write() state=off
Naming device: Door 0
Successfully created new {
            "triggers": [],
            "subscriptions": [],
            "type": "Switch",
            "name": "Door 0",
            "output": {
                "type": "CommandExecuterSwitch",
                "commandOn": "/home/pi/tea.sh",
                "commandOff": "/home/pi/tea.sh",
                "multithread": true
            },
            "invert": false,
            "initial": false,
            "input": {
                "type": "CommandReturnCode",
                "command": "/home/pi/door.py 0 status"
            },
            "ignoreRedundant": false
        }
Executing command: /home/pi/tea.sh
Optional input provided
Switch: write() state=off
Naming device: Door 1
Successfully created new {
            "triggers": [],
            "subscriptions": [],
            "type": "Switch",
            "name": "Door 1",
            "output": {
                "type": "CommandExecuterSwitch",
                "commandOn": "/home/pi/coffee.sh",
                "commandOff": "/home/pi/coffee.sh",
                "multithread": true
            },
            "invert": false,
            "initial": false,
            "input": {
                "type": "CommandReturnCode",
                "command": "/home/pi/door.py 1 status"
            },
            "ignoreRedundant": false
        }
Executing command: /home/pi/coffee.sh
Optional input provided
Switch: write() state=off
Naming device: Door 2
Successfully created new {
            "triggers": [],
            "subscriptions": [],
            "type": "Switch",
       No status data could be sent: $NOTIFY_SOCKET was not set
No status data could be sent: $NOTIFY_SOCKET was not set
No status data could be sent: $NOTIFY_SOCKET was not set
No status data could be sent: $NOTIFY_SOCKET was not set
No status data could be sent: $NOTIFY_SOCKET was not set
No status data could be sent: $NOTIFY_SOCKET was not set
No status data could be sent: $NOTIFY_SOCKET was not set
No status data could be sent: $NOTIFY_SOCKET was not set
No status data could be sent: $NOTIFY_SOCKET was not set
     "name": "Door 2",
            "output": {
                "type": "CommandExecuterSwitch",
                "commandOn": "/home/pi/olay.sh",
                "commandOff": "/home/pi/olay.sh",
                "multithread": true
            },
            "invert": false,
            "initial": false,
            "input": {
                "type": "CommandReturnCode",
                "command": "/home/pi/door.py 2 status"
            },
            "ignoreRedundant": false
        }Executing command: /home/pi/olay.sh

############# CONFIGURATIONS ##############
Device Configurations:
    ContactSensor
    Momentary
    MotionSensor
    RelativeHumidityMeasurement
    Switch
    SwitchLevel
    TemperatureMeasurement
    VoltageMeasurement

Composite Peripheral Configurations:
    DhtReader

InputBool Configurations:
    InputBoolRef
    InputDebouncer
    CommandReturnCode
    DigitalInputPinRaspberryPi

InputFloat Configurations:
    InputFloatRef
    CommandParser

InputUInt Configurations:
    InputUIntRef

OutputVoid Configurations:
    TimedOutputBool
    CommandExecuter
    DigitalOutputPinRaspberryPi

OutputBool Configurations:
    OutputBoolToFloat
    TimedOutputBool
    CommandExecuterSwitch
    DigitalOutputPinRaspberryPi

OutputFloat Configurations:
    PwmOutput
    ServoMotor

OutputString Configurations:

NetworkReceiver Configurations:
    NetworkReceiverHttpLib

NetworkSender Configurations:
    NetworkSenderHttpLib

############# DEVICES ##############
Devices:
    name=Door 0 type=Switch constantRun=1
    name=Door 1 type=Switch constantRun=1
    name=Door 2 type=Switch constantRun=1

############# TRIGGERS ##############
Triggers:

############# SUBSCRIPTIONS ##############
Subscriptions:

Initializing devices...
Starting http server thread...
Starting http server...
{"name": "Door 0", "type": "Switch", "switch": "on"}
{"name": "Door 1", "type": "Switch", "switch": "off"}
{"name": "Door 2", "type": "Switch", "switch": "on"}
Initializing scheduler...
Closing Door
Opening Door
Closing Door
Failed to operate door 0
Sending json: {"updates": [{"name": "Door 0", "type": "Switch", "switch": "on"},{"name": "Door 1", "type": "Switch", "switch": "off"},{"name": "Door 2", "type": "Switch", "switch": "on"}]}
Return value: 202
Detected switch Door 1 change to state=on
{"name": "Door 1", "type": "Switch", "switch": "on"}
emitting event=changed deviceName=Door 1
emitting event=on deviceName=Door 1
Detected switch Door 2 change to state=off
{"name": "Door 2", "type": "Switch", "switch": "off"}
emitting event=changed deviceName=Door 2
emitting event=off deviceName=Door 2
Sending json: {"updates": [{"name": "Door 1", "type": "Switch", "switch": "on"},{"name": "Door 2", "type": "Switch", "switch": "off"}]}
Return value: 202
No status data could be sent: $NOTIFY_SOCKET was not set
No status data could be sent: $NOTIFY_SOCKET was not set
No status data could be sent: $NOTIFY_SOCKET was not set

process returned: 0

process returned: 0

process returned: 0
DanielOgorchock commented 5 years ago

Does your smartthings log show it attempting to search for or create child devices at all? If not it likely isn't receiving any packets from the pi. The refresh events it's logging are ST requesting refreshed info from the pi, but IIRC I haven't implemented that on the omnithing side yet.

One thing to try is hitting the configure button in the ST app for the parent device. Going into and re-saving the settings also sometimes helps. I also recommend adding a "poll" trigger for each of your devices, so they will periodically communicate with smartthings even if there was no change.

The outputs being set to on/off on startup is an architectural limitation where the OutputBools initialize themselves to their initial values when constructed. I plan to add an actual door control device type which uses an OutputVoid to toggle the door. This should alleviate that issue, and I'll try to add that this week/weekend if I find the time.

sfalvey commented 5 years ago

It was reporting errors in the ST logs. But, bizzarely without changing anything its just started working.

The switches in the ST app seem to get stuck in turning on/turning off but the door is opening and closing on the required press. I have return codes open=0 and closed=1 for the operate command and the status command. Are these what determine the status for the ST app?

I have added the poll trigger as recommended and I'm happy to give your door code a test when you have it ready. Thanks for your help on this.