rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.94k stars 562 forks source link

HELP #1133

Open Nunsferatus opened 1 year ago

Nunsferatus commented 1 year ago

Let me start by saying that I'm a NOOB.

I've been trying to configure the sensors that I have in one of my plugs. I have tried everything that I could think of and I always get some kind of error. "Failed to restart Home Assistant The system cannot restart because the configuration is not valid: Integration error: sensor - Integration 'sensor' not found."

I'm really stuck and out of ideas. can anyone help me? It seems to work correctly in the template… image

Thanks for the help

Santanachia commented 1 year ago

don't use states.switch.plant_lights.voltage, use this instead:

state_attr('switch.plant_lights', 'voltage')

p.s. it is better when you copy the code than upload a photo.

Nunsferatus commented 1 year ago

Thank you for your help.

I have made the adjustment that you suggested

now I'm getting an error saying “duplicate key”

Doing this in the configuration.yaml Is this the correct place?

Once again thank you.

He is the code:

sensor:

On Mon, 21 Nov 2022 at 13:01, Marcin @.***> wrote:

don't use states.switch.plant_lights.voltage, use this instead:

state_attr('switch.plant_lights', 'voltage')

p.s. it is better when you copy the code than upload a photo.

— Reply to this email directly, view it on GitHub https://github.com/rospogrigio/localtuya/issues/1133#issuecomment-1321874136, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT7H4ZFYJRFZWVY7HO3FCUDWJNI7LANCNFSM6AAAAAASFMM65M . You are receiving this because you authored the thread.Message ID: @.***>

Santanachia commented 1 year ago

maybe it's just my subjective impression, but this code looks strange to me. In my case the custom sensor looks like this:

template:
  - sensor:
    - name: "Socket Voltage"
      state: "{{ float(states('sensor.smart_socket_voltage'), 0) / 10 }}"
      unique_id: madre_gniazdkoV
      unit_of_measurement: V