Skip to content

Commit

Permalink
1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
hakana committed Dec 10, 2024
1 parent 53fa993 commit 740d091
Show file tree
Hide file tree
Showing 13 changed files with 311 additions and 51 deletions.
7 changes: 3 additions & 4 deletions custom_components/shelly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
CONF_SCAN_INTERVAL, CONF_USERNAME, EVENT_HOMEASSISTANT_STOP,
__version__ as HAVERSION )
from homeassistant import config_entries
from homeassistant.helpers import discovery
from homeassistant.helpers import (discovery, entity_registry as er)
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.restore_state import RestoreStateData
from homeassistant.helpers.storage import Store
Expand Down Expand Up @@ -61,7 +61,7 @@

_LOGGER = logging.getLogger(__name__)

__version__ = "1.0.5"
__version__ = "1.0.6"
VERSION = __version__

async def async_setup(hass, config):
Expand Down Expand Up @@ -353,8 +353,7 @@ async def start_up(self):
'extra' : {'ip-addr': pys.host_ip}}
self.add_device("sensor", attr)

entity_reg = \
self.hass.helpers.entity_registry.async_get(self.hass)
entity_reg = er.async_get(self.hass)
entities_to_remove = []
entities_to_fix_attr = []
restore_expired = dt_util.as_utc(datetime.now()) - timedelta(hours=12)
Expand Down
54 changes: 27 additions & 27 deletions custom_components/shelly/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,23 @@

from datetime import timedelta

from homeassistant.components.sensor import (
SensorDeviceClass
)

from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass
)

from homeassistant.const import (
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_ENERGY,
TEMP_CELSIUS,
POWER_WATT,
ENERGY_WATT_HOUR,
UnitOfTemperature,
UnitOfPower,
UnitOfEnergy,
CONF_NAME,
CONF_SCAN_INTERVAL,
CONF_DISCOVERY
)

DEVICE_CLASS_MOTION = 'motion'

from homeassistant.components.binary_sensor import (
DEVICE_CLASS_CONNECTIVITY
)

DOMAIN = 'shelly'

CONF_ADDITIONAL_INFO = 'additional_information'
Expand Down Expand Up @@ -393,6 +390,7 @@
SENSOR_TYPE_MQTT_CONNECTED = 'mqtt_connected'
SENSOR_TYPE_SWITCH = 'switch'
SENSOR_TYPE_FLOOD = 'flood'
SENSOR_TYPE_SMOKE = 'smoke'
SENSOR_TYPE_DOOR_WINDOW = 'door_window'
SENSOR_TYPE_ILLUMINANCE = 'illuminance'
SENSOR_TYPE_TOTAL_CONSUMPTION = 'total_consumption'
Expand All @@ -415,44 +413,46 @@
SENSOR_TYPE_DEFAULT:
[None, None, None, None, None],
SENSOR_TYPE_TEMPERATURE:
['Temperature', TEMP_CELSIUS, None, DEVICE_CLASS_TEMPERATURE, None],
['Temperature', UnitOfTemperature.CELSIUS, None, SensorDeviceClass.TEMPERATURE, None],
SENSOR_TYPE_HUMIDITY:
['Humidity', '%', None, DEVICE_CLASS_HUMIDITY, None],
['Humidity', '%', None, SensorDeviceClass.HUMIDITY, None],
SENSOR_TYPE_POWER:
['Consumption', POWER_WATT, 'mdi:flash-outline', None, None],
['Consumption', UnitOfPower.WATT, 'mdi:flash-outline', None, None],
SENSOR_TYPE_RSSI:
['RSSI', 'dB', 'mdi:wifi', None, None],
SENSOR_TYPE_RSSI_LEVEL:
['RSSI Level', None, 'mdi:wifi', None, None],
SENSOR_TYPE_UPTIME:
['Uptime', 's', 'mdi:timer-outline', None, None],
SENSOR_TYPE_BATTERY:
['Battery', '%', None, DEVICE_CLASS_BATTERY, None],
['Battery', '%', None, SensorDeviceClass.BATTERY, None],
SENSOR_TYPE_OVER_POWER:
['Over power', None, 'mdi:flash-alert', None, 'bool'],
SENSOR_TYPE_OVER_VOLTAGE:
['Over voltage', None, 'mdi:flash-alert', None, 'bool'],
SENSOR_TYPE_DEVICE_TEMP:
['Device temperature', TEMP_CELSIUS, "mdi:oil-temperature", None, None],
['Device temperature', UnitOfTemperature.CELSIUS, "mdi:oil-temperature", None, None],
SENSOR_TYPE_OVER_TEMP:
['Over temperature', None, 'mdi:alert', None, 'bool'],
SENSOR_TYPE_CLOUD_STATUS:
['Cloud status', None, 'mdi:cloud-question', None, None],
SENSOR_TYPE_MQTT_CONNECTED:
['MQTT connected', None, 'mdi:transit-connection-variant',
DEVICE_CLASS_CONNECTIVITY, 'bool'],
BinarySensorDeviceClass.CONNECTIVITY, 'bool'],
SENSOR_TYPE_FLOOD:
['Flood', None, 'mdi:water', None, 'bool'],
SENSOR_TYPE_SMOKE:
['Flood', None, 'mdi:fire', None, 'bool'],
SENSOR_TYPE_DOOR_WINDOW:
['Door/Window', None, 'mdi:door', 'window', 'bool'],
SENSOR_TYPE_ILLUMINANCE:
['Illuminance', 'lux', None, DEVICE_CLASS_ILLUMINANCE, None],
['Illuminance', 'lux', None, SensorDeviceClass.ILLUMINANCE, None],
SENSOR_TYPE_TOTAL_CONSUMPTION:
['Total consumption', ENERGY_WATT_HOUR,
'mdi:lightning-bolt-circle', DEVICE_CLASS_ENERGY, None],
['Total consumption', UnitOfEnergy.WATT_HOUR,
'mdi:lightning-bolt-circle', SensorDeviceClass.ENERGY, None],
SENSOR_TYPE_TOTAL_RETURNED:
['Total returned', ENERGY_WATT_HOUR,
'mdi:lightning-bolt-circle', DEVICE_CLASS_ENERGY, None],
['Total returned', UnitOfEnergy.WATT_HOUR,
'mdi:lightning-bolt-circle', SensorDeviceClass.ENERGY, None],
SENSOR_TYPE_VOLTAGE:
['Voltage', 'V', 'mdi:alpha-v-circle-outline', None, None],
SENSOR_TYPE_POWER_FACTOR:
Expand All @@ -472,11 +472,11 @@
SENSOR_TYPE_EXT_SWITCH:
['External switch', None, 'mdi:electric-switch', None, 'bool'],
SENSOR_TYPE_MOTION:
['Motion', None, 'mdi:motion-sensor', DEVICE_CLASS_MOTION, 'bool'],
['Motion', None, 'mdi:motion-sensor', BinarySensorDeviceClass.MOTION, 'bool'],
SENSOR_TYPE_POSITION:
['Position', '', 'mdi:percent', None, None],
SENSOR_TYPE_TARGET_TEMP:
['Target temperature', TEMP_CELSIUS, "mdi:target-variant", None, None],
['Target temperature', UnitOfTemperature.CELSIUS, "mdi:target-variant", None, None],

}

84 changes: 76 additions & 8 deletions custom_components/shelly/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions custom_components/shelly/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
"typescript": "^4.4.4"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-brands-svg-icons": "^6.5.1",
"@fortawesome/free-regular-svg-icons": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"react-responsive-masonry": "^2.1.7"
}
}
17 changes: 14 additions & 3 deletions custom_components/shelly/frontend/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ export default {
format: "iife",
sourcemap: true,
},
watch: {
skipWrite: false,
clearScreen: false,
include: 'src/**/*',
//exclude: 'node_modules/**',
// chokidar: {exit
// paths: 'src/**/*',
// usePolling: false
// }
},
plugins: [
typescript(),
nodeResolve({
Expand All @@ -38,14 +48,15 @@ export default {
pnl.append(e)
`
}),
visualizer(),
//visualizer(),
/*serve({
open: true,
verbose: true,
contentBase: ["", "public"],
host: "localhost",
port: 3000,
}),*/
!production && livereload({ watch: "dist" }),
}),
!production && livereload({ watch: "src" }),
*/
]
};
3 changes: 2 additions & 1 deletion custom_components/shelly/frontend/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ export default function ShellyNavbar({narrow}) {
</NavItem>
: null
}
<Navbar.Brand as={Link} to="/">ShellyForHass</Navbar.Brand>
<Navbar.Brand as={Link} to="/">ShellyForHass!</Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav" >
<Nav className="me-auto" activeKey={loc.pathname}>
{/* <Nav.Link as={Link} to="/" eventKey="/">Devices</Nav.Link> */}
<Nav.Link as={Link} to="/devices" eventKey="/devices">Devices</Nav.Link>
<Nav.Link as={Link} to="/config" eventKey="/config">Config</Nav.Link>
<Nav.Link as={Link} to="/settings" eventKey="/settings">Settings</Nav.Link>
{/* <Nav.Link as={Link} to="/readme" eventKey="/readme">Readme</Nav.Link> */}
Expand Down
18 changes: 17 additions & 1 deletion custom_components/shelly/frontend/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@ export interface Instance {
hass: HomeAssistant,
instance_id : string,
settings : Setting[],
configs : Config[]
configs : Config[],
blocks : Blocks[]
}

export interface Blocks {
id : string,
name : string
room: string,
type: string,
img: string,
devices : Device[]
}

export interface Device {
id : string,
name : string,
state: string
}

export interface Config {
Expand Down
Loading

0 comments on commit 740d091

Please sign in to comment.