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

Shelly BLU Door/Window #164

Open
runcioa opened this issue Jul 8, 2024 · 11 comments
Open

Shelly BLU Door/Window #164

runcioa opened this issue Jul 8, 2024 · 11 comments

Comments

@runcioa
Copy link

runcioa commented Jul 8, 2024

I can't understand if it's already possibile to retrive Shelly BLU Window data from a node of a plus device.
In my case the Shelly BLU Window is connected via a Shelly Plus 1 Mini Gen3.

@windkh
Copy link
Owner

windkh commented Jul 8, 2024

Hm good question ... never tried that... I will check it out

@windkh
Copy link
Owner

windkh commented Jul 8, 2024

@runcioa
I guess that is doable. I need to find out first if I can detect if the bluetooth server is active in a shelly

@windkh
Copy link
Owner

windkh commented Jul 8, 2024

@windkh /rpc/BTHome.GetStatus contains an error property if bthome is not enabled
{
"errors": [
"observer_disabled"
]
}

@runcioa
Copy link
Author

runcioa commented Jul 9, 2024

I enable the BTHome and registered the device on components via mac address,

Component_Configuration

If i try:

curl -X POST -d '{"id":1,"method":"BTHomeSensor.GetStatus","params":{"id":200}}' http://192.168.2.41/rpc
The json response is:

{
  "id": 1,
  "src": "shelly1minig3-ecda3bc252b0",
  "result": {
    "id": 200,
    "value": false,
    "last_updated_ts": 1720552148
  }
}

"BTHomeSensor.GetStatus","params":{"id":200} identify the windows and if response value is true the windows is open otherwise is false

curl -X POST -d '{"id":1,"method":"BTHomeSensor.GetStatus","params":{"id":201}}' http://192.168.2.41/rpc
this is rotation and the response is:

{
  "id": 1,
  "src": "shelly1minig3-ecda3bc252b0",
  "result": {
    "id": 201,
    "value": 4.7,
    "last_updated_ts": 1720552422
  }
}

The value 4.7 is degree angle.

And so on.

@runcioa
Copy link
Author

runcioa commented Jul 9, 2024

If i make a post request like this:

{
  "id": 1,
  "method": "BTHomeDevice.GetKnownObjects",
  "params": {
    "id": 200
  }
}

the response is:

{
  "id": 1,
  "src": "shelly1minig3-ecda3bc252b0",
  "result": {
    "id": 200,
    "objects": [
      {
        "obj_id": 45,
        "idx": 0,
        "component": "bthomesensor:200"
      },
      {
        "obj_id": 63,
        "idx": 0,
        "component": "bthomesensor:201"
      },
      {
        "obj_id": 5,
        "idx": 0,
        "component": "bthomesensor:202"
      },
      {
        "obj_id": 1,
        "idx": 0,
        "component": "bthomesensor:203"
      },
      {
        "obj_id": 58,
        "idx": 0,
        "component": "bthomesensor:204"
      }
    ]
  }
}

With an obj_id you can use it to make a request with method BTHome.GetObjectInfos

{
  "id": 1,
  "method": "BTHome.GetObjectInfos",
  "params": {
    "obj_ids": [
      45,
      63,
      5,
      1
    ]
  }
} 

and the result is:

{
  "id": 1,
  "src": "shelly1minig3-ecda3bc252b0",
  "result": {
    "objects": [
      {
        "obj_id": 45,
        "obj_name": "window",
        "type": "binary_sensor",
        "unit": ""
      },
      {
        "obj_id": 63,
        "obj_name": "rotation",
        "type": "sensor",
        "unit": "°"
      },
      {
        "obj_id": 5,
        "obj_name": "illuminance",
        "type": "sensor",
        "unit": "lux"
      },
      {
        "obj_id": 1,
        "obj_name": "battery",
        "type": "sensor",
        "unit": "%"
      }
    ],
    "offset": 0,
    "count": 4,
    "total": 4
  }
}

@windkh
Copy link
Owner

windkh commented Jul 9, 2024

Well, the question is. Is it compatible with the blugateway or is it just another way to communicate with bt devices.

@runcioa
Copy link
Author

runcioa commented Jul 10, 2024

I don't have a blugateway, so i can't try.
The solution that i find for me is ok, because on nodered i make a simple POST request and I have the value of BT sensor.

The Bluegateway require a callback, i think is a bit more compicated.

@runcioa
Copy link
Author

runcioa commented Jul 11, 2024

I have another solution that require only one Post Request:

{
  "id": 1,
  "method": "Shelly.GetComponents"
}

the complete response is:

{
  "id": 1,
  "src": "shelly1minig3-ecda3bc252b0",
  "result": {
    "components": [
      {
        "key": "ble",
        "status": {},
        "config": {
          "enable": true,
          "rpc": {
            "enable": true
          },
          "observer": {
            "enable": true
          }
        }
      },
      {
        "key": "bthome",
        "status": {},
        "config": {}
      },
      {
        "key": "bthomedevice:200",
        "status": {
          "id": 200,
          "rssi": -72,
          "battery": 100,
          "packet_id": 90,
          "last_updated_ts": 1720634555
        },
        "config": {
          "id": 200,
          "addr": "38:39:8f:74:b1:4f",
          "name": null,
          "key": null,
          "meta": {
            "ui": {
              "view": "Last updated",
              "icon": null
            }
          }
        }
      },
      {
        "key": "bthomesensor:200",
        "status": {
          "id": 200,
          "value": 100,
          "last_updated_ts": 1720634555
        },
        "config": {
          "id": 200,
          "addr": "38:39:8f:74:b1:4f",
          "name": "Battery",
          "obj_id": 1,
          "idx": 0,
          "meta": {
            "ui": {
              "icon": null
            }
          }
        }
      },
      {
        "key": "bthomesensor:201",
        "status": {
          "id": 201,
          "value": 22.00,
          "last_updated_ts": 1720634555
        },
        "config": {
          "id": 201,
          "addr": "38:39:8f:74:b1:4f",
          "name": " illuminance",
          "obj_id": 5,
          "idx": 0,
          "meta": {
            "ui": {
              "icon": null
            }
          }
        }
      },
      {
        "key": "bthomesensor:202",
        "status": {
          "id": 202,
          "value": false,
          "last_updated_ts": 1720634555
        },
        "config": {
          "id": 202,
          "addr": "38:39:8f:74:b1:4f",
          "name": null,
          "obj_id": 45,
          "idx": 0,
          "meta": null
        }
      },
      {
        "key": "bthomesensor:203",
        "status": {
          "id": 203,
          "value": 0.0,
          "last_updated_ts": 1720634555
        },
        "config": {
          "id": 203,
          "addr": "38:39:8f:74:b1:4f",
          "name": null,
          "obj_id": 63,
          "idx": 0,
          "meta": null
        }
      },
      {
        "key": "cloud",
        "status": {
          "connected": true
        },
        "config": {
          "enable": true,
          "server": "shelly-35-eu.shelly.cloud:6022/jrpc"
        }
      },
      {
        "key": "input:0",
        "status": {
          "id": 0,
          "state": false
        },
        "config": {
          "id": 0,
          "name": null,
          "type": "switch",
          "enable": true,
          "invert": false,
          "factory_reset": true
        }
      },
      {
        "key": "mqtt",
        "status": {
          "connected": true
        },
        "config": {
          "enable": true,
          "server": "192.168.2.60:1883",
          "client_id": "shelly1minig3-ecda3bc252b0",
          "user": null,
          "ssl_ca": null,
          "topic_prefix": "shelly1minig3-ecda3bc252b0",
          "rpc_ntf": false,
          "status_ntf": false,
          "use_client_cert": false,
          "enable_rpc": false,
          "enable_control": true
        }
      },
      {
        "key": "script:1",
        "status": {
          "id": 1,
          "running": false,
          "mem_free": 25200
        },
        "config": {
          "id": 1,
          "name": "abc",
          "enable": false
        }
      },
      {
        "key": "script:2",
        "status": {
          "id": 2,
          "running": false,
          "mem_free": 25200
        },
        "config": {
          "id": 2,
          "name": "script_2",
          "enable": false
        }
      },
      {
        "key": "switch:0",
        "status": {
          "id": 0,
          "source": "SHC",
          "output": false,
          "temperature": {
            "tC": 59.1,
            "tF": 138.4
          }
        },
        "config": {
          "id": 0,
          "name": null,
          "in_mode": "follow",
          "initial_state": "match_input",
          "auto_on": false,
          "auto_on_delay": 60.00,
          "auto_off": false,
          "auto_off_delay": 60.00
        }
      }
    ],
    "cfg_rev": 331,
    "offset": 0,
    "total": 16
  }
}

with all parameters (name and value) that i need.

@windkh
Copy link
Owner

windkh commented Jul 11, 2024

Good idea. So the only thing to find out is how the shelly will forward the changes in the sensor data like for the callback mode...

@windkh
Copy link
Owner

windkh commented Sep 19, 2024

I added the option to install the blu gateway script to a standard gen2+ device.

@windkh
Copy link
Owner

windkh commented Sep 19, 2024

@runcioa first iteration was added to V11.2.0. Now let's talk about what else we could do here. Any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants