ShellyForHass custom component

If anybody will need this:

In lovelace code just replace “light.shelly_rgbw2_dnevna” with name of your shelly RGBW2 name light.

Final code:
image

sensor.yaml

  - platform: template
    sensors:
      variable_obvestilo_rgbw2_white:
        friendly_name: BELA SVETLOBA
        value_template: ""
        icon_template: mdi:alpha-w-box
  - platform: template
    sensors:
      variable_obvestilo_rgbw2_color:
        friendly_name: BARVNA SVETLOBA
        value_template: ""
        icon_template: mdi:palette

lovelace:

entities:
  - light.shelly_rgbw2_dnevna
  - entity: sensor.variable_obvestilo_rgbw2_white
  - attribute: white_value
    entity: light.shelly_rgbw2_dnevna
    full_row: true
    step: 1
    type: 'custom:slider-entity-row'
  - entity: sensor.variable_obvestilo_rgbw2_color
  - entity: light.shelly_rgbw2_dnevna
    full_row: true
    step: 1
    type: 'custom:slider-entity-row'
  - colors:
      - brightness: 220
        effect: 'Off'
        icon_color: '#c0c0c0'
        rgb_color:
          - 255
          - 255
          - 255
        transition: 1
        white_value: 0
      - brightness: 220
        effect: 'Off'
        icon_color: '#990000'
        rgb_color:
          - 255
          - 0
          - 0
        transition: 1
        white_value: 0
      - brightness: 220
        effect: 'Off'
        icon_color: '#009900'
        rgb_color:
          - 0
          - 255
          - 0
        transition: 1
        white_value: 0
      - brightness: 220
        effect: 'Off'
        icon_color: '#999900'
        rgb_color:
          - 255
          - 255
          - 0
        transition: 1
        white_value: 0
      - brightness: 220
        effect: 'Off'
        icon_color: '#009999'
        rgb_color:
          - 0
          - 255
          - 255
        transition: 1
        white_value: 0
      - brightness: 220
        effect: Gradual change
        icon_color: center/120% url('/local/images/rainbow.png')
        transition: 1
        white_value: 0
      - brightness: 3
        effect: 'Off'
        icon_color: center/95% url('/local/images/night_mode.png')
        transition: 1
        white_value: 0
    entity: light.shelly_rgbw2_dnevna
    justify: between
    type: 'custom:rgb-light-card'
show_header_toggle: false
title: LED trak
type: entities

Icons:
Put files under: config\www\images
night_mode
rainbow

And additional components:
ShellyForHass (Shelly integration)
rgb-light-card
slider-entity-row

1 Like

Hi, I have problem with automation, in other word with white_value on automation…

If I’m using:

# Prižgi LED luč: ZUNAJ
- id: '114'
  alias: ZUNAJ - prižgi LED (zvečer)
  trigger:
#    platform: time
#    at: '17:00:00'
    platform: template
    value_template: "{{ states('sensor.time') == (states.input_datetime.variable_zunaj_prizgi_led_zvecer.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
  action:
    - service: light.turn_on
      data:
        entity_id: light.shelly_rgbw2_zunaj
        brightness: 230
        rgb_color: [255,255,255]

then all is working…

But if I want to set white_value, then automation is not working…

# Prižgi LED luč: ZUNAJ
- id: '114'
  alias: ZUNAJ - prižgi LED (zvečer)
  trigger:
#    platform: time
#    at: '17:00:00'
    platform: template
    value_template: "{{ states('sensor.time') == (states.input_datetime.variable_zunaj_prizgi_led_zvecer.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
  action:
    - service: light.turn_on
      data:
        entity_id: light.shelly_rgbw2_zunaj
        brightness: 1
        rgb_color: [255,255,255]
        white_value: 230

With this kind code I can control white value, but can not control then RGB value…

- id: '114'
  alias: ZUNAJ - prižgi LED (zvečer)
  trigger:
#    platform: time
#    at: '17:00:00'
    platform: template
    value_template: "{{ states('sensor.time') == (states.input_datetime.variable_zunaj_prizgi_led_zvecer.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"
  action:
    - service: light.turn_on
      data:
        entity_id: light.shelly_rgbw2_zunaj
        rgb_color: [255,255,255]
    - service: light.turn_on
      data:
        entity_id: light.shelly_rgbw2_zunaj
        brightness: 1
    - service: light.turn_on
      data:
        entity_id: light.shelly_rgbw2_zunaj
        white_value: 230

Goal is to control both, RGBW + white at the same time…

Thank you…

Hi all, if you find a bug, please open an issue at https://github.com/StyraHem/ShellyForHASS/issues

Thank you,

Simone

1 Like

Hi all, Quick question,
All my shellys are not on my network
but they are using the cloud.
Will this component still work?
thank you

What do you mean when you say that the Shellies are not on your network? Are they in another location?

The Shellies must be connected to the same network as your Home Assistant system. If that’s the case, this component will work whether or not the Shellies are also on the cloud.

yes they are at my mom/dads house.
Ok so, it doesnt work with the cloud only.
Thanks you for the answer.

Hi,
would it be possible for you to add a combined current consumption in kwh so we can use it with utility meter for daily/monthly meters?

I am doing this sum myself, but after every restart I get a really weird value for some time and it messes up my monthly/yearly meters.

Just curious, I’m currently using my shellys via mqtt, and all is well, but to try it out I loaded the integration and I can’t seem to get it to find any devices. My wifi is a diff vlan and I have multicast forwarding setup on my router. Is there anything else I may be missing? Thanks!

Is CoAP enabled? My entities have the following attribute:

protocols: CoAP-discovery, poll, CoAP-msg, mDns

Skye,

I apologize but do you mean in the Device itself or in the integration?

JB

In the device settings, by default it should be on though. I do believe when you enable mqtt it disables automatically.

I am using just shellyforhass to control my two shelly 2.5’s and I really like the implementation. There are too many rabbit holes to go down right now for me so I do not want to get into mqtt just yet.

My only gripe is I am trying to be very consistent with my entity ids and names (like all power sensors end in _power, not _current_consumption). I tried integrating with GUI first but it kept renaming my entities back to its auto generated ones. Now using yaml and thought it was solved but last reboot changed my power entity_id and names again.

I know that you can override the auto generated names but I dont know how to specify it down to each entity_id vice each device. For instance my Shelly 2.5 - 10BC51 has 2 device id’s one for each switch:
Shelly 2.5 - 10BC51-1 and Shelly 2.5 - 10BC51-2. the 10BC51-1 goes to my entertainment center outlet so I want the entity id of the power to be named as such. The relay will be disabled to never turn off, and the switch will actually operate my couch lights via automation. So I want that switch entity to be named couch lights.

If I could set all that stuff in stone via yaml that would be great, it is very tedious to keep renaming the entities via GUI even for just two shelly 2.5s so I will not be adding any more until I can get a solution to this

Just set up two shelly 1 switches. The integration discovered the switches and they can be controlled by the HA GUI. The only issue is the status in lovelace seems to take a full pooling interval, which is at the default of 60 seconds, before the GUI updates indicating a change. Anyone aware of a configuration option to make the switch state update happen shortly after the initial click?

I am using it, but I only have 1 Shelly4. It works without any problems.

1 Like

I’m using several Shelly1 and Shelly2.5 and they react instantly. How is the signal quality for these Shelly’s? Do you have the same behaviour in the Shelly app?

I should have been clearer. The issue is associated with using a “Picture Elements Card”. Using the shelly web interface works without issue. If I use just a “Entities Card” to toggle on and off it work as expected. The “Picture Elements Card” appears to wait for the status in the database to actually be updated, which doesn’t happen until the polling interval. I use a picture elements card because it allows the displaying of a floor plan.

Actually if I switch the light off using the picture element card and then look at the entities card, the entity card also doesn’t update until the polling interval. So the entity card only appears to work because the GUI changes the state immediately if you click on that toggle.

The shelly 1 support mqtt, which I hadn’t previously utilized in my implementation. I enabled the HA provided mqtt broker, changed the switch to communicate with the broker and then configured the sensors in my ha configuration.yaml. This approach provides the expected performance. Configuration was pretty simple:

switch:
  - platform: mqtt
    name: "backbed mqtt shelly"
    state_topic: "shellies/shelly1-98F4ABD0B919/relay/0"
    command_topic: "shellies/shelly1-98F4ABD0B919/relay/0/command"
    payload_on: "on"
    payload_off: "off"
    retain: false
  - platform: mqtt
    name: "famroom mqtt shelly"
    state_topic: "shellies/shelly1-8CAAB505E297/relay/0"
    command_topic: "shellies/shelly1-8CAAB505E297/relay/0/command"
    payload_on: "on"
    payload_off: "off"
    retain: false

The shelly1-XXXXX value can be read from the log when the switch connects to the broker.

You can use the option light_switch to change it to a light

I don’t know if you asked anything else?

You need CoAP multicast working in your network. You can look on the attribute “protocols” and see if “coap-msg” are there. The CoAP working, other there is poll, mDns etc. coap-discovery mening it is discovered but coap-msg is where it get the status updates.

You can try enable/disable igmp in your router/switch/AP.

Are they running on different VLANS?

What do you mean with signal quality?