Shelly4hass and native Shelly integration

The Shelly4hass custom integration and the native shelly integration use the same domain “shelly”. This is the reason why you cannot use both at the same time.
But it is possible to move Shelly4hass to a new domain.

  • shut down homeassistant (this is important. You have to change HA files while HA is not running. Otherwise, HA will overwrite your changes)

  • in the custom_components/shelly directory change const.py
    DOMAIN = ‘shelly’ → DOMAIN = ‘shelly4h’

  • in the custom_components/shelly directory change manifest.json
    “domain”: “shelly” → “domain”: “shelly4h”,
    “name”: “Shelly” → “name”: “Shelly4hass”

  • in config_flow.py:
    return self.async_create_entry(
    title=“Shelly4hass”,
    data=system_options
    )
    and
    async def async_step_final(self):
    return self.async_create_entry(
    title=“Shelly4hass”,
    data=self._options
    )

  • in .homeassistant/.storage/core.config_entries:

    “domain”: “shelly4h”,
    and
    “title”: “Shelly4hass”,

  • in .homeassistant/.storage/core.device_registry:
    “identifiers”: [[“shelly4h”,…]]

  • in .homeassistant/.storage/core.entity_registry:
    “platform”:“shelly4” “shelly4h”

  • in configuration.yaml:
    shelly: → shelly4h: (if you have that)

You shoud not be using ShellyForHass

ShellyForHass will no longer receive further development updates. This decision stems from the fact that its features and functionality have been seamlessly integrated into Home Assistant, making it redundant to maintain a separate plugin.

https://github.com/StyraHem/ShellyForHASS?tab=readme-ov-file#discontinuation-of-shellyforhass

Just use the core integration.

It is not possible to use the core integration while you have Shelly4hass still active. This means you have to migrate somehow from Shelly4hass to Shelly native.

  1. Delete S4H
  2. Install HA core Shelly integration.

Do you think the native Shelly integration takes over the 50 old S4H entities?
And if not, how do I know what “shelly_shem_3_d8bfc01a7fae_1_current_consumption” is that is used in 4 automations and 3 template sensors?

Yes. Why wouldn’t it?

Why the heck did you not rename your Shelly’s to something easily recognisable like mains_power?

Also you can add the Shelly devices discovered by the core integration one by one and rename them as you go. You don’t have to add them all at once.

You never migrated from Shell4hass to shelly, right?

Correct I never had the need for Shell4hass. Right from when I started using Shelly devices five years ago, back then mqtt and the HA restful integration was all that was needed for full functionality but as the core Shelly integration got better I switched over to that.

Thanks! This might be really helpful for us who still struggle with migrating. Could you confirm this does not change the entity_ids of the devices at all?
My key issue is the energy data and long term statistics. I want to keep it and if I understand correctly I cannot reboot between renaming the entities but if I can do them one by one then that would be a really great trick.

With my receipe, you have both shelly integrations in parallel and the entity ids are kept.

Thing is Tom that S4H uses the same domain, shelly, which is the same as the native integration. Sure you can remove S4H and then in your own pace add them one by one back to native Shelly but as you understand you will loose the devices in the mean time. On top off that you will loose all long term stats including energy data.

Moving from S4H is not trivial at all if you require all data to be kept. This solution does not automate any of the steps no, but it heavily reduces the risk of data loss and continuous labour. If I would do all of this in one go I know I have to complete it at the same session as I start it. This method removes that obstacle as well.

Unfortunately this did not go as planned. I cannot find a way to delete devices or even entities provided by S4H. Since I cannot delete them on the fly I cannot give the new entities from the official integration the same ID.

Have you managed to successfully migrated and kept LTS and Energy data?

After updating to HA 2024.12.0b3 all my shelly4hass devices are unavailable.

1 Like

Long term statistics are not deleted just like that. You are either missing devices with the same entity_ids or those devices have now different entity_ids:

  1. Add new device with that same entity_id and LTS will reappear.
  2. Change entity_ids of sensors back (from before integration switch) and LTS will reappear.

:wink:

i changed all the shelly to shelly4h after rebooting in save mode - seems like it worked. Not so easy to put the vm data partition in a sd card slot :wink:

Spook is very helpful to find all sorts of things with missing entities (after renaming or similar)

So can anyone who has actually done this give any clarification.

The method above allows both to exist, but as above you can have two entities with the same ID and you cant delete an entity in shelly for hass - so whilst it is nice in one way it does not solve the probiem.

I have 80 devives and 80 automations. It runs my house.

I have just delete Shelly for hass and add the shelly native integration then does anyone know what happens? Do the devices have the same names and entity IDs in the native integation so all is well or do i have to rename them all ( bear in mind shelly call them something like “getr35904359fe39f” which was dealt with at the time they were added and renamed , but now i will have 80 random entities to identify and then goto to 80 automations and hop i can figure it out.

Since the native shelly integration is a completly different product, it does scanning and naming of the shellys completely different. So the entity names are not the same. Migration is not automated.

So the " process " is delete shelly for hass , enable the native integration and then sort out the considerable mess in every automation and script ?

When they new devices join do they pick up the Shelly name or just the id ? Ie " 8593jfj884" as an id or " lounge dimmer "

At least the latter makes some sense and then I " just" have to work through every script and automation.

If you first delete shelly4hass, everything stops working and it is very difficult to migrate. If you run shelly4hass and native shelly in parallel, you can migrate one device every day until you are finished.
The entity names of the native shelly integration are like that: “sensor.shellyplug_s_ab913b_energy” when the mac address is “xx:xx:xx:AB:91:3B”