Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Support for Sonoff SPM with device_type: diy_meter #658

Closed
rpimeekle opened this issue Dec 19, 2021 · 19 comments
Closed

Feature request: Support for Sonoff SPM with device_type: diy_meter #658

rpimeekle opened this issue Dec 19, 2021 · 19 comments
Labels
wontfix This will not be worked on
Milestone

Comments

@rpimeekle
Copy link

Feature Request:

Support for Sonoff Smart Stackable Power Meter (Sonoff SPM)

I have read through the docs and issues, and even went through the python code, but couldn't find anything relating to this device. The closest I could see was in reference to diy_plug.
Can support please be added for this device: Sonoff SPM.

The API docs for the device_type: diy_meter can be found here: http://developers.sonoff.tech/spm-main-http-api.html

Some testing I have done with the API docs:

I have been able to test the device in DIY mode using the suggested POST methods and almost everything works. The only thing I have had trouble with is the Real-Time Monitoring setup. While all the other POST only use the device ID and sub-device IDs, this option requires setting an ambiguous url and port. Whether that is the ip-address and port for the device itself, or a real-time monitoring application external to the device, I haven't been able to determine. If I have a random url and port, it responds but without any data, and if i drop the url and port, the http POST request fails to connect.

Regardless, it would be amazing if this device could be added to this custom_component.

Let me know if you need further information.

@rpimeekle rpimeekle changed the title Feature request: Support for Sonoff Stackable Power Meter (SPM) with device_type diy_meter Feature request: Support for Sonoff SPM with device_type: diy_meter Dec 19, 2021
@AlexxIT AlexxIT added the enhancement New feature or request label Dec 19, 2021
@AlexxIT
Copy link
Owner

AlexxIT commented Dec 19, 2021

I can't promise anything. There is not enough time to add new devices at the moment

@rpimeekle
Copy link
Author

I can't promise anything. There is not enough time to add new devices at the moment

That's fair.

I might do some more digging then. I'll fork the project and see what I can do to add the component myself (I've been wanting to sink my teeth into something like this, so this seems like a good opportunity).

@thomasfowler
Copy link

Hi All

I know this is an old thread, but I would be quite keen to contribute here as well. I've now installed a bunch of these SPM units now and am super keen to get the power consumption data into hassio.

@rpimeekle did you make any progress?

@AlexxIT I did a quick scan of the repo - is there a contributors guide or guide to getting a local dev env setup or something like that to get me started and moving in the right direction?

@rpimeekle
Copy link
Author

Hi All

I know this is an old thread, but I would be quite keen to contribute here as well. I've now installed a bunch of these SPM units now and am super keen to get the power consumption data into hassio.

@rpimeekle did you make any progress?

@AlexxIT I did a quick scan of the repo - is there a contributors guide or guide to getting a local dev env setup or something like that to get me started and moving in the right direction?

@thomasfowler I didn't make any progress with this side of things, however, I did get the device working with Node Red and feeding back to Home Assistant.

See my blog post here.

@AlexxIT
Copy link
Owner

AlexxIT commented Mar 27, 2022

@thomasfowler there is no contributors guide. I have started developing new version but the war crushed some plans.

@AlexxIT
Copy link
Owner

AlexxIT commented Apr 23, 2022

Can it be added to ewelink app? I need a debug logs from this device

@thomasfowler
Copy link

@AlexxIT yes, it can be added to ewelink. I can provide these logs if needed.

I also have my device here hooked up being polled using the mDNS service, so I can provide a view of the objects returned. Let me know how I can help and am happy to pitch in here.

@AlexxIT
Copy link
Owner

AlexxIT commented Apr 26, 2022

First of all I'm interesting in debug logs with cloud protocol. You can add device to cloud and collect this logs via this Integration (in debug mode)

@Yocee84
Copy link

Yocee84 commented May 1, 2022

In V2.4.6 the smp is worked fine. Ampere, Watt, Volt, i seen everything. I upgrade to 3.0.1, and disappered lot stuff. Only show swiches for SPM cannels.

@AlexxIT
Copy link
Owner

AlexxIT commented May 5, 2022

You need to go to device page and click download diagnostics

@thomasfowler
Copy link

@AlexxIT Here are the debug logs for the SPM Main and the single sub-device. Let me know what else you need

SPM Main

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2022.5.3",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.9.9",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Africa/Johannesburg",
    "os_name": "Linux",
    "os_version": "5.10.108",
    "supervisor": "2022.05.1",
    "host_os": "Home Assistant OS 7.6",
    "docker_version": "20.10.9",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "hacs": {
      "version": "1.24.5",
      "requirements": [
        "aiogithubapi>=21.11.0"
      ]
    },
    "sonoff": {
      "version": "3.0.5",
      "requirements": [
        "pycryptodome>=3.6.6"
      ]
    }
  },
  "integration_manifest": {
    "domain": "sonoff",
    "name": "Sonoff",
    "config_flow": true,
    "documentation": "https://github.com/AlexxIT/SonoffLAN",
    "issue_tracker": "https://github.com/AlexxIT/SonoffLAN/issues",
    "codeowners": [
      "@AlexxIT"
    ],
    "dependencies": [
      "http",
      "zeroconf"
    ],
    "requirements": [
      "pycryptodome>=3.6.6"
    ],
    "version": "3.0.5",
    "iot_class": "local_push",
    "is_built_in": false
  },
  "data": {
    "version": "200f243",
    "cloud_auth": true,
    "config": {
      "username": "***",
      "password": "***",
      "rfbridge": {
        "Study PIR": {
          "device_class": "motion",
          "timeout": 15
        },
        "School PIR": {
          "device_class": "motion",
          "timeout": 15
        },
        "Garage PIR": {
          "device_class": "motion",
          "timeout": 15
        }
      },
      "devices": {
        "10010b4b11": {
          "device_class": "switch",
          "name": "Pool Pump"
        },
        "10010b54f4": {
          "device_class": "switch",
          "name": "Pond Pump"
        },
        "1000f59fd1": {
          "device_class": "switch",
          "name": "Right Garage Door"
        },
        "1000f5964d": {
          "device_class": "switch",
          "name": "Left Garage Door"
        },
        "1000f594fa": {
          "device_class": "switch",
          "name": "Gate"
        }
      }
    },
    "options": {},
    "errors": [],
    "device": {
      "uiid": 128,
      "params": {
        "version": 8,
        "rssi": -43,
        "timeZone": 2,
        "subDevices": [
          {
            "subDevId": "3059464e3635361635363236",
            "deviceid": "ab30000101",
            "uiid": "130"
          }
        ],
        "sledOnline": "on",
        "fwVersion": "1.2.0",
        "subChipFwVer": "1.2.0",
        "only_device": {
          "ota": "start"
        }
      },
      "model": "SPM-Main",
      "online": true,
      "localtype": null,
      "deviceid": "10014a7357"
    }
  }
}

Sub Device

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2022.5.3",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.9.9",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Africa/Johannesburg",
    "os_name": "Linux",
    "os_version": "5.10.108",
    "supervisor": "2022.05.1",
    "host_os": "Home Assistant OS 7.6",
    "docker_version": "20.10.9",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "hacs": {
      "version": "1.24.5",
      "requirements": [
        "aiogithubapi>=21.11.0"
      ]
    },
    "sonoff": {
      "version": "3.0.5",
      "requirements": [
        "pycryptodome>=3.6.6"
      ]
    }
  },
  "integration_manifest": {
    "domain": "sonoff",
    "name": "Sonoff",
    "config_flow": true,
    "documentation": "https://github.com/AlexxIT/SonoffLAN",
    "issue_tracker": "https://github.com/AlexxIT/SonoffLAN/issues",
    "codeowners": [
      "@AlexxIT"
    ],
    "dependencies": [
      "http",
      "zeroconf"
    ],
    "requirements": [
      "pycryptodome>=3.6.6"
    ],
    "version": "3.0.5",
    "iot_class": "local_push",
    "is_built_in": false
  },
  "data": {
    "version": "200f243",
    "cloud_auth": true,
    "config": {
      "username": "***",
      "password": "***",
      "rfbridge": {
        "Study PIR": {
          "device_class": "motion",
          "timeout": 15
        },
        "School PIR": {
          "device_class": "motion",
          "timeout": 15
        },
        "Garage PIR": {
          "device_class": "motion",
          "timeout": 15
        }
      },
      "devices": {
        "10010b4b11": {
          "device_class": "switch",
          "name": "Pool Pump"
        },
        "10010b54f4": {
          "device_class": "switch",
          "name": "Pond Pump"
        },
        "1000f59fd1": {
          "device_class": "switch",
          "name": "Right Garage Door"
        },
        "1000f5964d": {
          "device_class": "switch",
          "name": "Left Garage Door"
        },
        "1000f594fa": {
          "device_class": "switch",
          "name": "Gate"
        }
      }
    },
    "options": {},
    "errors": [],
    "device": {
      "uiid": 130,
      "params": {
        "bindInfos": "***",
        "subDevId": "3059464e3635361635363236",
        "parentid": "10014a7357",
        "fwVersion": "1.0.0",
        "overload_00": {
          "delayTime": 5,
          "maxAP": {
            "en": 1,
            "val": 440000
          },
          "maxC": {
            "en": 1,
            "val": 2000
          },
          "maxV": {
            "en": 1,
            "val": 24000
          },
          "minAP": {
            "en": 0,
            "val": 10
          },
          "minV": {
            "en": 0,
            "val": 10
          }
        },
        "overload_01": {
          "delayTime": 5,
          "maxAP": {
            "en": 1,
            "val": 440000
          },
          "maxC": {
            "en": 1,
            "val": 2000
          },
          "maxV": {
            "en": 1,
            "val": 24000
          },
          "minAP": {
            "en": 0,
            "val": 10
          },
          "minV": {
            "en": 0,
            "val": 10
          }
        },
        "overload_02": {
          "delayTime": 5,
          "maxAP": {
            "en": 1,
            "val": 440000
          },
          "maxC": {
            "en": 1,
            "val": 2000
          },
          "maxV": {
            "en": 1,
            "val": 24000
          },
          "minAP": {
            "en": 0,
            "val": 10
          },
          "minV": {
            "en": 0,
            "val": 10
          }
        },
        "overload_03": {
          "delayTime": 5,
          "maxAP": {
            "en": 1,
            "val": 440000
          },
          "maxC": {
            "en": 1,
            "val": 2000
          },
          "maxV": {
            "en": 1,
            "val": 24000
          },
          "minAP": {
            "en": 0,
            "val": 10
          },
          "minV": {
            "en": 0,
            "val": 10
          }
        },
        "switches": [
          {
            "switch": "on",
            "outlet": 0
          },
          {
            "switch": "on",
            "outlet": 1
          },
          {
            "switch": "on",
            "outlet": 2
          },
          {
            "switch": "on",
            "outlet": 3
          }
        ],
        "threshold": {
          "actPow": {
            "min": 10,
            "max": 440000
          },
          "current": {
            "min": 10,
            "max": 2000
          },
          "voltage": {
            "min": 10,
            "max": 24000
          }
        },
        "timers": "***",
        "getKwh_03": 2,
        "uiActive": {
          "outlet": 3,
          "time": 60
        },
        "actPow_03": 0,
        "apparentPow_03": 0,
        "current_03": 0,
        "reactPow_03": 0,
        "voltage_03": 22716,
        "endTime_03": "2022-03-20T11:38:52.548Z",
        "startTime_03": "2022-03-20T11:36:18.558Z",
        "iAmHere": 1,
        "faultState": {
          "cse7761Com": [
            1,
            1,
            1,
            1
          ],
          "overLimit": [
            {
              "outlet": 3,
              "rsn": [
                0
              ]
            }
          ],
          "subDevCom": 1
        },
        "configure": [
          {
            "outlet": 0,
            "startup": "off"
          },
          {
            "outlet": 1,
            "startup": "off"
          },
          {
            "outlet": 2,
            "startup": "off"
          },
          {
            "outlet": 3,
            "startup": "off"
          }
        ],
        "rangeEnd": 29,
        "rangeStart": 0,
        "getKwh_00": 2,
        "actPow_01": 0,
        "apparentPow_01": 0,
        "current_01": 0,
        "reactPow_01": 0,
        "voltage_01": 22648
      },
      "model": "GD32-SM4(130)",
      "online": true,
      "localtype": null,
      "deviceid": "ab30000101"
    }
  }
}

AlexxIT added a commit that referenced this issue May 14, 2022
@AlexxIT
Copy link
Owner

AlexxIT commented May 14, 2022

@thomasfowler thanks. Adds support to latest master version. I'm not sure if all fine with control sub-device. And not sure if all fine with online power measurements.

Unfortunately devices not working locally in your network. So I can't support LAN protocol.

@thomasfowler
Copy link

@AlexxIT not sure what you mean about "Unfortunately devices not working locally in your network" - is there something else you need me to do?

I have simply added them using the eWelink App and then loaded the diagnostic information from the UI. Is there something else that needs to be done?

@AlexxIT
Copy link
Owner

AlexxIT commented May 21, 2022

Your devices have empty localtype. That means they can't be found locally in your network
https://github.com/AlexxIT/SonoffLAN#mode

@thomasfowler
Copy link

thomasfowler commented May 25, 2022

@AlexxIT I've been looking into this. FWIW, I have upgraded the firmware on the SPM to the latest version offered by the eWeLink app (version 1.2.0) and I have update my SonoffLAN integration to use the laster version in master branch.

I have confirmed that the SPM is connected to my LAN and I can consistently ping it. It is on the same LAN as my Home Assistant instance (no VLANS or other segments).

I don't have any other issues with Multicast on my network - mDNS is working for all my other devices.

By way of example, I have another 33 Sonoff devices on my network (plugs and light switches) and they dont seem to have a problem with localtype.

By way of example, a BASICRF_R3 has "localtype": "plug" and a TX2C has "localtype": "strip".

So the problem with discovering the SPM locally on my network seems to be isolated to only the SPM and not other Sonoff devices.

I've also been able to work with device using mDNS in DIY mode, and didn't have any discovery problems then. In fact, here is a screenshot of the SPM via my local mDNS browser, with the encrypted data blacked out:

image

So I don't think mDNS or multicast is the problem...

Any advice on where to go next?

@jebeke65
Copy link

jebeke65 commented Jul 8, 2022

does someone know how to setup the service the Sonoff SPM needs to connect to to send the energy measurements ?

@nicofamdj
Copy link

nicofamdj commented Feb 9, 2023

Im trying to get the SPM-MAIN with 3 sub devices (4RELAY) to get to work in DIY mode.

In HASS im getting in the overview Unknown DIY

  "data": {
    "version": "5406fa7",
    "cloud_auth": false,
    "config": {
      "mode": "local",
      "reload": "always",
      "debug": true,
      "devices": {
        "100015661b1": {
          "name": "DUCOSPMLOCAL",
          "host": "192.168.51.117:8081"
        },
        "ab300004cf": {
          "device_class": [
            {
              "switch": [
                1,
                2,
                3,
                4
              ]
            }
          ],
          "name": "DUCOU1LOCAL",
          "host": "192.168.51.117:8081"
        }
      }
    },
    "options": {},
    "errors": [],
    "devices": {
      "6732474c3831310c45373439": {
        "uiid": 0,
        "params": {
          "switches": [
            {
              "switch": "off",
              "outlet": 2
            }
          ]
        },
        "model": "diy_meter",
        "online": null,
        "localtype": "diy_meter",
        "host": "192.168.51.117:8081"
      }
    }
  }
}

@AlexxIT
Copy link
Owner

AlexxIT commented Mar 31, 2023

Sonoff SPM connected to eWeLink cloud should work fine via cloud and local protocols in the latest master version.

I think I can't add it as DIY device, because don't have it. I would recommend using it with a connection to the cloud.

@AlexxIT AlexxIT added wontfix This will not be worked on and removed enhancement New feature or request labels Mar 31, 2023
@AlexxIT AlexxIT added this to the 3.5.1 milestone Mar 31, 2023
@AlexxIT
Copy link
Owner

AlexxIT commented Mar 31, 2023

@AlexxIT AlexxIT closed this as completed Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

6 participants