jpcornil-git/HA-mcp23017

why every time raspberry Pi4 power on, all switch will ALL ON?

Closed this issue · 10 comments

Hello, thanks for your add-on. now i use these config code, every time when home assistant start up, all switch will ALL ON. can you tell me , how to let all switch output ALL OFF or don't change state when home assistant reboot.
switch:

  • platform: mcp23017
    i2c_address: 0x22
    invert_logic: true
    pins:
    0 : Output_1
    1 : Output_2
    2 : Output_3
    3 : Output_4
    4 : Output_5
    5 : Output_6
    6 : Output_7
    7 : Output_8
    8 : Output_9
    9 : Output_10
    10 : Output_11
    11 : Output_12
    12 : Output_13
    13 : Output_14
    14 : Output_15
    15 : Output_16

If mcp23017 is not reset by your hardware or by a power cycle, switch states shouldn't change given your configuration.

hw_sync parameter is indeed not defined and therefore set to True (default value); this means that the integration should read mcp23017 states when HA starts up for these entities.

I guess that when HA starts up, your mcp23017 hardware is also reset somehow and therefore outputs reset to their default values, i.e. 0 (ON with invert_logic set to True).

Could you describe your hardware and what do you mean exactly with "home assistant start up" ?

here the pdf is diagram of MCP23017 circuit.
CM4 i2c bus connect with MCP23017 -> 74HCT14 -> ULN2003 -> RELAY
"home assistant start up" means: power ON of raspberry pi4
do you means, i should add:
"hw_sync: true " and set "invert_logic: false" ?
Thanks for your help.
inout_V1.2.pdf

Thanks for the schematic, is the 3V3 used by the mcp23017 supplied from CM4's CM4_3.3V (Output) (pin 84 & 86 see p20 of CM4 datasheet) ?

If it is the case, then 3V3 goes down during a power cycle if I read correctly.

I guess that if you just restart HA (but not CM4) then output levels are preserved ?

  1. 3V3 used by the mcp23017 supplied from CM4's CM4_3.3V (Output) --> NO, not connected directly.
    CM4 use by 5v power.

  2. i power off and on of DC12v power supply, so when power off, CM4 and MCP23017 both no power. my CM4 and MCP23017 build in one PCB.

If mcp23017 loose its power then related states are also lost, i.e. when everything restart you get power on reset default states (OFF with invert_logic=False ON otherwise).

Note that if you use config flow rather than yaml to configure a mcp23017 then you can set invert_logic per entity rather than per device (with yaml you can change it using the UI but it is not persistent).

if i set "invert_logic=False" , when power on of PCB, all relay also will all ON, just home assitant UI switch state exchanged. do you think it's hardware circuit problem?

It is not a hardware issue but the expected behavior; mcp23017 sets its output registers to 0 after reset/power up, invert_logic only affects HA state/how you see it.

i sloved, just need add "hw_sync: false" will be ok. thank you very much for your help. we will make new pcb with 4pcs of MCP23017, 32 channel binary sensor + 32 channel switch. your component support that , OK?

hw_sync=False will force output to OFF at power up from a UI/HA perspective (for mcp23017 this is 0 with invert_logic=False, 1 otherwise).

No issues with support for multiples mcp23017 devices as long as they are on the same i2c bus.

OK, thanks again.