DIY lightswitch based on a sphero mini

In this topic,
I show how to turn a sphero mini robotic ball into a rule-based, customizable switch for e.g the light, presence detection, and more.
I have done this completely over GUI,
so textual config users unfortunately can’t do this untill somone “translates” it into textual config mode.
I will post the “code” out of the “code” section of the items, rules and things so you can also do and customize this for your instllation.

Steps:
1.find the MAC address of your sphero mini (testing needed for other sphero robots)
2. create the thing:

UID: bluetooth:beacon:hci1:26db090a38
label: SM
thingTypeUID: bluetooth:beacon
configuration:
  address: MACADDR
bridgeUID: bluetooth:bluez:hci0

(replace MACADDR with your MAC address you found e.g. in the bluetooth settings of a device connected to the sphero, or in the sphero app)
2. link the channel RSSI of the created thing to a number item, and name it for example “Sphero_RSSI”
3. create a dummy switch item (no links to channels, we need it later for the rules and automation) and name it e.g. sphero_switch
4. measure the RSSI of the sphero thing you created if the sphero is at the point where it should trigger “ON”, and note it, we will need it later
5. rules:
OFF:

triggers:
  - id: "1"
    configuration:
      itemName: RSSI_SPHERO
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: RSSI_SPHERO
      state: "your RSSI - 5"
      operator: <
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: switchitem
      command: OFF
    type: core.ItemCommandAction

ON:

triggers:
  - id: "1"
    configuration:
      itemName: RSSI_SPHERO
    type: core.ItemStateChangeTrigger
conditions:
  - inputs: {}
    id: "2"
    configuration:
      itemName: RSSI_SPHERO
      state:  "your RSSI - 5"
      operator: ">"
    type: core.ItemStateCondition
actions:
  - inputs: {}
    id: "3"
    configuration:
      itemName: switchitem
      command: ON
    type: core.ItemCommandAction

with this up and running, you can react with rules to event the sphero is at its point or leaves it.
I for example have a rule which switches the light on if i put the robot in its “base” (i have built myself a base for it with lego bricks) , and switches it off if i remove it from the base.
it has a delay of ~5 seconds, but it is okay if you have a sphero lying around and are searching for a switch you already have and which is integrated into openhab.
(NOTE: i havent tried out how long the sphero’s battery lasts, but i think it is 1 week or more, and then 2 hours of charging (do this when you don’t need the switch, for example at night.))
Have fun with your new DIY openhab sensor :smiley: :smiley:

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.