Multiple sensors help please

Hi folks,

Really basic question and the frustration was I had it sorted but it was lost before I could save the code / snapshot off … ;-(

I am trying to put a dual non-intrusive power monitor solution together for a mate to monitor his grid and solar meters and I have his RPi3B (that got corrupted on an update and hence how I lost what I’d done) and have the two opto-transistors wired up to an ESP8266 and have one working fine with the following code:

sensor:
platform: pulse_counter
pin: GPIO05
unit_of_measurement: ‘Watts’
update_interval: 20s
accuracy_decimals: 0
name: ‘Grid Power’
filters:

  • multiply: 60
    internal_filter: 10us

But every time I try to add the second sensor with something like this:

platform: pulse_counter
pin: GPIO04
unit_of_measurement: ‘Watts’
update_interval: 20s
accuracy_decimals: 0
name: ‘Solar Power’
filters:

  • multiply: 60
    internal_filter: 10us

It complains about duplicate platforms and if I get rid of that it then complains about the pin and I’m just tired and would like it working please … ;-(

Could anyone offer the solution that works for me to save somewhere safe this time please …

Cheers, T i m

p.s. My fairly comprehensive (~60+ Zigbee / ESP devices) on an Odroid N2+ system
seems to be pretty reliable.

Post your code properly please.

Hi Nick,

Sorry, I never saved the code because it didn’t work but I have just now (searches the forum for how to post code …)

<snip std stuff>
sensor:
   platform: pulse_counter
   pin: GPIO05
   unit_of_measurement: 'Watts' 
   update_interval: 20s 
   accuracy_decimals: 0 
   name: 'Grid Power' 
   filters: 
   - multiply: 60
   internal_filter: 10us
   
   platform: pulse_counter
   pin: GPIO04
   unit_of_measurement: 'Watts' 
   update_interval: 20s 
   accuracy_decimals: 0 
   name: 'Solar Power' 
   filters: 
   - multiply: 60
   internal_filter: 10us   
   
   
switch:
  - platform: restart
    name: "Restart"   

IHTH, cheers, Tim

Does it just need dashes ?

sensor:
  - platform: pulse_counter
    pin: GPIO05
    unit_of_measurement: 'Watts' 
    update_interval: 20s 
    accuracy_decimals: 0 
    name: 'Grid Power' 
    filters: 
      - multiply: 60
    internal_filter: 10us
   
  - platform: pulse_counter
    pin: GPIO04
    unit_of_measurement: 'Watts' 
    update_interval: 20s 
    accuracy_decimals: 0 
    name: 'Solar Power' 
    filters: 
      - multiply: 60
    internal_filter: 10us

Brilliant.

Thank you so much. Whilst when I’m doing loads of ‘poke and hope’ / ‘copy > paste’ and ‘standing on the shoulders of giants’ coding I can often muddle my way though but in this case I was particularly frustrated because 1) it was late and I’d spent more than enough time on it … 2) just wanted a working solution (for someone else as an appliance) and 3) did have it working previously (or at lest the code) and it had been lost because of an update. ;-(

My problem is at 65 years old and even after spending most of my career in IT via electronics repair / datacomms field support / IT Training and building my first home computer (from a kit), the ZX81, I’ve never really been able to code. ;-(

I really think it’s a form of ‘blindness’, like people get with words or numbers … along with a really poor memory for things that aren’t intuitive.

So I do what I can, especially on the practical / electronics side and sometimes have to rely on good people like those helping others here.

The frustration is that I really love the whole Home Automation thing and especially Home Assistant and am like a kid when I come home with another brand / model of Zigbee lamp or switch and get it working for me. :wink:

The last instance of that was replacing 3 outdoor lamps with smart versions (Ikea, Lidl and Philips Hue) and triggering them with a SonOff PIR in a home 3D printed ceiling fitting and on the lux condition read from an ESP32 and a light level sensor. Every time I walk out into the back yard at night and the lights come on it makes me smile. :wink:

Simple things eh. :wink:

Thanks again for the prompt reply and solution.

T i m

This may help YAML - Home Assistant

Hi Nick, sorry for the delay and thanks for the reply.

I think it’s too late for me to become good / comfortable coder as soon as I see code I just go blank (in many cases).

I also don’t enjoy it and this is part of the remit for me and HA, along with the practical benefits (most of which I managed without etc).

So there is little point me trying to learn how to do it because the learning curve is just too steep and unlike those things that I do seem to have an intuitive interaction with that I learn and retain, coding isn’t one of them.

Like the simple missing - thing. I have probably been there before and not realised / forgotten and so no other code changes (and I’d tried a lot) made the slightest difference. What I do is try to build up a library of routines that work and try to cobble them together as required.

I do have a good relationship with a coder and in return for his coding help, I help him with his electronics questions.

Ironically, I have been in IT Support most of my life so giving support (with nothing in return) is just part of me. :wink:

Cheers, T i m