Skip to content

Update __init__.py - Error correction + fix PCF8574 multi-output overwrite + I2C lock + persistence + multi-device support#4

Open
gumazza wants to merge 1 commit into
PiBrewing:mainfrom
gumazza:patch-1
Open

Update __init__.py - Error correction + fix PCF8574 multi-output overwrite + I2C lock + persistence + multi-device support#4
gumazza wants to merge 1 commit into
PiBrewing:mainfrom
gumazza:patch-1

Conversation

@gumazza
Copy link
Copy Markdown

@gumazza gumazza commented Jan 19, 2026

Summary

This PR fixes a critical issue where activating one PCF8574 output would unintentionally disable the others.

Changes

  • Write full 8-bit state to PCF8574 (required by hardware)
  • Added async I2C bus lock
  • Added persistent state across CBPi4 restarts
  • Added support for multiple PCF8574 devices (0x20–0x27)
  • Added sequential relay test action
  • Updated CBPi4 API imports (CBPiActor)

Hardware tested

  • Raspberry Pi 4
  • PCF8574
  • ULN2803 relay driver
  • Relays active LOW

Result

  • Outputs are now fully independent
  • Multiple relays can be active simultaneously
  • Stable behavior under concurrent actor updates

### Summary
This PR fixes a critical issue where activating one PCF8574 output would unintentionally disable the others.

### Changes
- Write full 8-bit state to PCF8574 (required by hardware)
- Added async I2C bus lock
- Added persistent state across CBPi4 restarts
- Added support for multiple PCF8574 devices (0x20–0x27)
- Added sequential relay test action
- Updated CBPi4 API imports (CBPiActor)

### Hardware tested
- Raspberry Pi 4
- PCF8574
- ULN2803 relay driver
- Relays active LOW

### Result
- Outputs are now fully independent
- Multiple relays can be active simultaneously
- Stable behavior under concurrent actor updates
@avollkopf
Copy link
Copy Markdown
Member

I will look into it, but it'll take some time as I will be travelling the next coouple of days.

Quick question after brief review: Where do you get the "/tmp/pcf8574_state.json" file from.

This might not be working for others.

@gumazza
Copy link
Copy Markdown
Author

gumazza commented Feb 8, 2026

It was a suggestion from chatGPT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants