Skip to content

Commit

Permalink
Add Plus Mini devices (#242)
Browse files Browse the repository at this point in the history
* Add Plus PM Mini

* Add Plus 1 Mini

* Rename TOPIC_PM to TOPIC_STATUS_PM1

* Add Plus 1PM Mini
  • Loading branch information
bieniu authored Jul 25, 2023
1 parent 4c28f7d commit 3e9f34e
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ Shellies Discovery Gen2 will automatically install/update the script on your She
## Supported devices

- Shelly Plus 1
- Shelly Plus 1 Mini
- Shelly Plus 1PM
- Shelly Plus 1PM Mini
- Shelly Plus 2PM
- Shelly Plus Add-on
- Shelly Plus H&T
Expand All @@ -38,6 +40,7 @@ Shellies Discovery Gen2 will automatically install/update the script on your She
- Shelly Plus Plug S
- Shelly Plus Plug UK
- Shelly Plus Plug US
- Shelly Plus PM Mini
- Shelly Plus Smoke
- Shelly Plus Wall Dimmer
- Shelly Pro 1
Expand Down
3 changes: 3 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ Shellies Discovery Gen2 will automatically install/update the script on your She
## Supported devices

- Shelly Plus 1
- Shelly Plus 1 Mini
- Shelly Plus 1PM
- Shelly Plus 1PM Mini
- Shelly Plus 2PM
- Shelly Plus Add-on
- Shelly Plus H&T
Expand All @@ -31,6 +33,7 @@ Shellies Discovery Gen2 will automatically install/update the script on your She
- Shelly Plus Plug S
- Shelly Plus Plug UK
- Shelly Plus Plug US
- Shelly Plus PM Mini
- Shelly Plus Smoke
- Shelly Plus Wall Dimmer
- Shelly Pro 1
Expand Down
157 changes: 155 additions & 2 deletions python_scripts/shellies_discovery_gen2.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,28 @@
KEY_VALUE_TEMPLATE = "val_tpl"

MODEL_PLUS_1 = "shellyplus1"
MODEL_PLUS_1_MINI = "shelly1mini"
MODEL_PLUS_1PM = "shellyplus1pm"
MODEL_PLUS_1PM_MINI = "shelly1pmmini"
MODEL_PLUS_2PM = "shellyplus2pm"
MODEL_PLUS_HT = "shellyplusht"
MODEL_PLUS_I4 = "shellyplusi4"
MODEL_PLUS_PLUG_IT = "shellyplusplugit"
MODEL_PLUS_PLUG_S = "shellyplusplugs"
MODEL_PLUS_PLUG_UK = "shellypluspluguk"
MODEL_PLUS_PLUG_US = "shellyplugus"
MODEL_PLUS_PM_MINI = "shellypmmini"
MODEL_PLUS_SMOKE = "shellyplussmoke"
MODEL_PLUS_WALL_DIMMER = "shellypluswdus"
MODEL_PRO_1 = "shellypro1"
MODEL_PRO_1PM = "shellypro1pm"
MODEL_PRO_2 = "shellypro2"
MODEL_PRO_2PM = "shellypro2pm"
MODEL_PRO_3 = "shellypro3"
MODEL_PRO_DUAL_COVER_PM = "shellypro2cover"
MODEL_PRO_EM = "shellyproem50"
MODEL_PRO_3EM = "shellypro3em"
MODEL_PRO_4PM = "shellypro4pm"
MODEL_PRO_DUAL_COVER_PM = "shellypro2cover"
MODEL_PRO_EM = "shellyproem50"
MODEL_WALL_DISPLAY = "ShellyWallDisplay"

SENSOR_ACTIVE_POWER = "active_power"
Expand Down Expand Up @@ -228,6 +231,7 @@
TOPIC_SHELLIES_DISCOVERY_SCRIPT = "shelies_discovery_script"
TOPIC_STATUS_CLOUD = "~status/cloud"
TOPIC_STATUS_DEVICE_POWER = "~status/devicepower:0"
TOPIC_STATUS_PM1 = "~status/pm1:0"
TOPIC_STATUS_RPC = "~status/rpc"
TOPIC_STATUS_SMOKE = "~status/smoke:0"
TOPIC_STATUS_SYS = "~status/sys"
Expand Down Expand Up @@ -256,6 +260,7 @@
TPL_EMETER_TOTAL_APPARENT_POWER = "{{value_json.total_aprt_power}}"
TPL_EMETER_TOTAL_CURRENT = "{{value_json.total_current}}"
TPL_EMETER_VOLTAGE = "{{{{value_json.{phase}_voltage}}}}"
TPL_FREQUENCY = "{{value_json.freq}}"
TPL_ENERGY = "{{value_json.aenergy.total}}"
TPL_ETH_IP = "{{value_json.eth.ip}}"
TPL_EXTERNAL_POWER = "{%if value_json.external.present%}ON{%else%}OFF{%endif%}"
Expand Down Expand Up @@ -404,6 +409,16 @@
KEY_UNIT: UNIT_AMPERE,
KEY_VALUE_TEMPLATE: TPL_EMETER_TOTAL_CURRENT,
}
DESCRIPTION_SENSOR_CURRENT_PM = {
KEY_DEVICE_CLASS: DEVICE_CLASS_CURRENT,
KEY_ENABLED_BY_DEFAULT: False,
KEY_NAME: "Current",
KEY_STATE_CLASS: STATE_CLASS_MEASUREMENT,
KEY_STATE_TOPIC: TOPIC_STATUS_PM1,
KEY_SUGGESTED_DISPLAY_PRECISION: 1,
KEY_UNIT: UNIT_AMPERE,
KEY_VALUE_TEMPLATE: TPL_CURRENT,
}
DESCRIPTION_SENSOR_CURRENT_COVER = {
KEY_DEVICE_CLASS: DEVICE_CLASS_CURRENT,
KEY_ENABLED_BY_DEFAULT: False,
Expand All @@ -424,6 +439,16 @@
KEY_UNIT: UNIT_WATTH,
KEY_VALUE_TEMPLATE: TPL_ENERGY,
}
DESCRIPTION_SENSOR_ENERGY_PM = {
KEY_DEVICE_CLASS: DEVICE_CLASS_ENERGY,
KEY_ENABLED_BY_DEFAULT: True,
KEY_NAME: "Energy",
KEY_STATE_CLASS: STATE_CLASS_TOTAL_INCREASING,
KEY_STATE_TOPIC: TOPIC_STATUS_PM1,
KEY_SUGGESTED_DISPLAY_PRECISION: 1,
KEY_UNIT: UNIT_WATTH,
KEY_VALUE_TEMPLATE: TPL_ENERGY,
}
DESCRIPTION_SENSOR_ENERGY_COVER = {
KEY_DEVICE_CLASS: DEVICE_CLASS_ENERGY,
KEY_ENABLED_BY_DEFAULT: True,
Expand Down Expand Up @@ -489,6 +514,16 @@
KEY_UNIT: UNIT_WATT,
KEY_VALUE_TEMPLATE: TPL_POWER,
}
DESCRIPTION_SENSOR_POWER_PM = {
KEY_DEVICE_CLASS: DEVICE_CLASS_POWER,
KEY_ENABLED_BY_DEFAULT: True,
KEY_NAME: "Power",
KEY_STATE_CLASS: STATE_CLASS_MEASUREMENT,
KEY_STATE_TOPIC: TOPIC_STATUS_PM1,
KEY_SUGGESTED_DISPLAY_PRECISION: 1,
KEY_UNIT: UNIT_WATT,
KEY_VALUE_TEMPLATE: TPL_POWER,
}
DESCRIPTION_SENSOR_EMETER_ACTIVE_POWER = {
KEY_DEVICE_CLASS: DEVICE_CLASS_POWER,
KEY_ENABLED_BY_DEFAULT: True,
Expand Down Expand Up @@ -658,6 +693,36 @@
KEY_UNIT: UNIT_VOLT,
KEY_VALUE_TEMPLATE: TPL_VOLTAGE,
}
DESCRIPTION_SENSOR_VOLTAGE_PM = {
KEY_DEVICE_CLASS: DEVICE_CLASS_VOLTAGE,
KEY_ENABLED_BY_DEFAULT: False,
KEY_NAME: "Voltage",
KEY_STATE_CLASS: STATE_CLASS_MEASUREMENT,
KEY_STATE_TOPIC: TOPIC_STATUS_PM1,
KEY_SUGGESTED_DISPLAY_PRECISION: 1,
KEY_UNIT: UNIT_VOLT,
KEY_VALUE_TEMPLATE: TPL_VOLTAGE,
}
DESCRIPTION_SENSOR_FREQUENCY = {
KEY_DEVICE_CLASS: DEVICE_CLASS_FREQUENCY,
KEY_ENABLED_BY_DEFAULT: False,
KEY_NAME: "Frequency",
KEY_STATE_CLASS: STATE_CLASS_MEASUREMENT,
KEY_STATE_TOPIC: TOPIC_SWITCH_RELAY,
KEY_SUGGESTED_DISPLAY_PRECISION: 0,
KEY_UNIT: UNIT_HERTZ,
KEY_VALUE_TEMPLATE: TPL_FREQUENCY,
}
DESCRIPTION_SENSOR_FREQUENCY_PM = {
KEY_DEVICE_CLASS: DEVICE_CLASS_FREQUENCY,
KEY_ENABLED_BY_DEFAULT: False,
KEY_NAME: "Frequency",
KEY_STATE_CLASS: STATE_CLASS_MEASUREMENT,
KEY_STATE_TOPIC: TOPIC_STATUS_PM1,
KEY_SUGGESTED_DISPLAY_PRECISION: 0,
KEY_UNIT: UNIT_HERTZ,
KEY_VALUE_TEMPLATE: TPL_FREQUENCY,
}
DESCRIPTION_SENSOR_EMETER_FREQUENCY = {
KEY_DEVICE_CLASS: DEVICE_CLASS_FREQUENCY,
KEY_ENABLED_BY_DEFAULT: False,
Expand Down Expand Up @@ -871,6 +936,34 @@
},
ATTR_MIN_FIRMWARE_DATE: 20230209,
},
MODEL_PLUS_1_MINI: {
ATTR_NAME: "Shelly Plus 1 Mini",
ATTR_MODEL_ID: "SNSW-001X8EU",
ATTR_BINARY_SENSORS: {SENSOR_CLOUD: DESCRIPTION_SENSOR_CLOUD},
ATTR_BUTTONS: {BUTTON_RESTART: DESCRIPTION_BUTTON_RESTART},
ATTR_INPUTS: 1,
ATTR_INPUT_BINARY_SENSORS: {SENSOR_INPUT: DESCRIPTION_SENSOR_INPUT},
ATTR_INPUT_EVENTS: [
EVENT_SINGLE_PUSH,
EVENT_DOUBLE_PUSH,
EVENT_LONG_PUSH,
EVENT_TRIPLE_PUSH,
],
ATTR_RELAYS: 1,
ATTR_RELAY_SENSORS: {SENSOR_TEMPERATURE: DESCRIPTION_SENSOR_RELAY_TEMPERATURE},
ATTR_RELAY_BINARY_SENSORS: {SENSOR_OVERTEMP: DESCRIPTION_SENSOR_OVERTEMP},
ATTR_SENSORS: {
SENSOR_LAST_RESTART: DESCRIPTION_SENSOR_LAST_RESTART,
SENSOR_SSID: DESCRIPTION_SENSOR_SSID,
SENSOR_WIFI_IP: DESCRIPTION_SENSOR_WIFI_IP,
SENSOR_WIFI_SIGNAL: DESCRIPTION_SENSOR_WIFI_SIGNAL,
},
ATTR_UPDATES: {
UPDATE_FIRMWARE: DESCRIPTION_UPDATE_FIRMWARE,
UPDATE_FIRMWARE_BETA: DESCRIPTION_UPDATE_FIRMWARE_BETA,
},
ATTR_MIN_FIRMWARE_DATE: 20230718,
},
MODEL_PLUS_1PM: {
ATTR_NAME: "Shelly Plus 1PM",
ATTR_MODEL_ID: "SNSW-001P16EU",
Expand Down Expand Up @@ -909,6 +1002,44 @@
},
ATTR_MIN_FIRMWARE_DATE: 20230209,
},
MODEL_PLUS_1PM_MINI: {
ATTR_NAME: "Shelly Plus 1PM Mini",
ATTR_MODEL_ID: "SNSW-001P8EU",
ATTR_BINARY_SENSORS: {SENSOR_CLOUD: DESCRIPTION_SENSOR_CLOUD},
ATTR_BUTTONS: {BUTTON_RESTART: DESCRIPTION_BUTTON_RESTART},
ATTR_INPUTS: 1,
ATTR_INPUT_BINARY_SENSORS: {SENSOR_INPUT: DESCRIPTION_SENSOR_INPUT},
ATTR_INPUT_EVENTS: [
EVENT_SINGLE_PUSH,
EVENT_DOUBLE_PUSH,
EVENT_LONG_PUSH,
EVENT_TRIPLE_PUSH,
],
ATTR_RELAYS: 1,
ATTR_RELAY_BINARY_SENSORS: {
SENSOR_OVERPOWER: DESCRIPTION_SENSOR_OVERPOWER,
SENSOR_OVERTEMP: DESCRIPTION_SENSOR_OVERTEMP,
SENSOR_OVERVOLTAGE: DESCRIPTION_SENSOR_OVERVOLTAGE,
},
ATTR_RELAY_SENSORS: {
SENSOR_CURRENT: DESCRIPTION_SENSOR_CURRENT,
SENSOR_ENERGY: DESCRIPTION_SENSOR_ENERGY,
SENSOR_POWER: DESCRIPTION_SENSOR_POWER,
SENSOR_VOLTAGE: DESCRIPTION_SENSOR_VOLTAGE,
SENSOR_FREQUENCY: DESCRIPTION_SENSOR_FREQUENCY,
},
ATTR_SENSORS: {
SENSOR_LAST_RESTART: DESCRIPTION_SENSOR_LAST_RESTART,
SENSOR_SSID: DESCRIPTION_SENSOR_SSID,
SENSOR_WIFI_IP: DESCRIPTION_SENSOR_WIFI_IP,
SENSOR_WIFI_SIGNAL: DESCRIPTION_SENSOR_WIFI_SIGNAL,
},
ATTR_UPDATES: {
UPDATE_FIRMWARE: DESCRIPTION_UPDATE_FIRMWARE,
UPDATE_FIRMWARE_BETA: DESCRIPTION_UPDATE_FIRMWARE_BETA,
},
ATTR_MIN_FIRMWARE_DATE: 20230718,
},
MODEL_PLUS_2PM: {
ATTR_NAME: "Shelly Plus 2PM",
ATTR_MODEL_ID: "SNSW-002P16EU",
Expand Down Expand Up @@ -1122,6 +1253,28 @@
},
ATTR_MIN_FIRMWARE_DATE: 20220211,
},
MODEL_PLUS_PM_MINI: {
ATTR_NAME: "Shelly Plus PM Mini",
ATTR_MODEL_ID: "SNPM-001PCEU16",
ATTR_BINARY_SENSORS: {SENSOR_CLOUD: DESCRIPTION_SENSOR_CLOUD},
ATTR_BUTTONS: {BUTTON_RESTART: DESCRIPTION_BUTTON_RESTART},
ATTR_SENSORS: {
SENSOR_CURRENT: DESCRIPTION_SENSOR_CURRENT_PM,
SENSOR_ENERGY: DESCRIPTION_SENSOR_ENERGY_PM,
SENSOR_FREQUENCY: DESCRIPTION_SENSOR_FREQUENCY_PM,
SENSOR_LAST_RESTART: DESCRIPTION_SENSOR_LAST_RESTART,
SENSOR_POWER: DESCRIPTION_SENSOR_POWER_PM,
SENSOR_SSID: DESCRIPTION_SENSOR_SSID,
SENSOR_VOLTAGE: DESCRIPTION_SENSOR_VOLTAGE_PM,
SENSOR_WIFI_IP: DESCRIPTION_SENSOR_WIFI_IP,
SENSOR_WIFI_SIGNAL: DESCRIPTION_SENSOR_WIFI_SIGNAL,
},
ATTR_UPDATES: {
UPDATE_FIRMWARE: DESCRIPTION_UPDATE_FIRMWARE,
UPDATE_FIRMWARE_BETA: DESCRIPTION_UPDATE_FIRMWARE_BETA,
},
ATTR_MIN_FIRMWARE_DATE: 20230718,
},
MODEL_PLUS_SMOKE: {
ATTR_BATTERY_POWERED: True,
ATTR_NAME: "Shelly Plus Smoke",
Expand Down

0 comments on commit 3e9f34e

Please sign in to comment.