Error on installing a script for case fan control and power button from command line

Oh nice! Iā€™ll try this as soon as I can, and I will let you know if it works! Thanks a lot

@Misiu I just tried to install the integration, but I catch an error at the last step:

    1. Add argon40 : to your configuration.yaml

If I add this to my configuration, Hassio tells me:

The following integrations and platforms could not be set up:
  - argon40
Please check your config.

Would you like talk about this in your GitHub repo, through an issue?

EDIT: It seems to be caused by i2c, which I did activate following this, but the logs show me that is not enabled.

2020-06-11 14:05:47 ERROR (MainThread) [homeassistant.setup] Error during setup of component argon40
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/smbus/smbus.py", line 81, in open
    self._fd = os.open(path, os.O_RDWR, 0)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/config/custom_components/argon40/__init__.py", line 34, in async_setup
    bus = SMBus(1)
  File "/usr/local/lib/python3.7/site-packages/smbus/smbus.py", line 56, in __init__
    self.open(bus)
  File "/usr/local/lib/python3.7/site-packages/smbus/smbus.py", line 83, in open
    raise IOError(e.errno)
OSError: 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 190, in _async_setup_component
    result = await asyncio.wait_for(task, SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/config/custom_components/argon40/__init__.py", line 64, in async_setup
    address,
UnboundLocalError: local variable 'address' referenced before assignment

Sadly I donā€™t have access to my test environment till the end of the week.
There is an easier way to enable I2c, you need to plug SD card to your PC and edit a single file, but I canā€™t find the instructions. Iā€™ll post it here and in my repo if I find and test them.

I followed thoses instructions I2c not working on the Pi4
And it works for i2c, now I have /dev/i2c-1 available.

But sadly, I figured out that adding argon40: to my configuration.yml is breaking completely the loading of my HomeAssistant instance. No specific logs via SSH, but the frontend refuse to load.

EDIT:

I found logs after added argon40: in my configuration.yaml:

20-06-12 19:21:42 ERROR (MainThread) [supervisor.homeassistant] Error on call https://172.30.32.1:8123/api/config:

It occurs many times, until I comment argon40: in configuration.yaml. Unfortunately, I donā€™t know where to find HomeAssistant API logs :confused:

Sorry for late reply.
What version of Home Assistant you have?
Iā€™ll try to debug everything on both PI3 and PI4, but I still donā€™t have the case so Iā€™ll be asking for help.
You can log issues in my repo or post them here :slight_smile:

I just received my Argon one for my raspberry pi 4 :slight_smile:

I would like to help and test your addon.
The problem is each time I uncomment the line ā€œdtparam=i2c_arm=onā€ to get i2c, the pi doesnā€™t boot anymore. I was using this method I2c not working on the Pi4

Hi, no worries about replying late :wink:

I just open an issue on your repo: https://github.com/Misiu/argon40/issues/1

We could talk about this there, and go back here once the component will be ready?

2 Likes

Nice work on the custom component. Canā€™t believe argon40 has not addressed this.

1 Like

Tried implementing this but I get invalid config error on startup. Any ideas?

big thank you to @Misiu for the custom component!! I manage to get it working. Biggest difficulty for me was to enable l2c as the partition for hass overlay did not show up when i plug in into my PC so i couldnt change the file and ended up having to load up Linux to do it

For everyone having trouble with I2C/1wire - Iā€™ve created a feature request Allow enabling I2C and 1wire via Home Assistant CLI.
Please upvote it :pleading_face:
Enabling both interfaces should be much easier and properly documented.

1 Like

Iā€™m trying to enable I2C on my PI4. Did you follow those instructions on Windows?
I was able to finally do it, but I canā€™t remember which instructions I follow.
Iā€™ve tried the one you linked (but I only see hassos-boot), then I tried https://github.com/home-assistant/operating-system/blob/ec6f7978b52823098c3d555f14c6097d0eb33916/Documentation/boards/raspberrypi.md#i2c and https://www.home-assistant.io/hassio/enable_i2c/

I want to find a proper way and correct the docs so it will work on PI4.

Hi Misiu,

Thanks for putting together this custom component!

FYI This is the method I used to enable I2C on my Raspberry Pi 4 Model B.

Your Argon40 component works great. I threw together an automation for HA to regulate the fan speed in discrete steps based on CPU temp which seems to be working smoothly.

Do you think you could add compatibility for the power button? It would be nice if it showed up as a sort of momentary switch in HA to be used in automations. To be honest, Iā€™m not entirely sure what I would do with it, but because itā€™s on the Argon case it would be nice to have for use in HA.

Thanks again!

Iā€™ve tried that guide on a fresh installed HassOS (4.10) and I failed.
Iā€™m using Windows to create those files, so maybe that was the problem? Iā€™ve tried saving files as ANSI and as UTF8, Iā€™ve changed new line character from CR LF to LF (Unix style) and I had no luck :confused:
When I think about that, the only thing I didnā€™t try was to use another USB stick.
What USB port did you use? 2.0 or 3.0?
Do you remember if something should show in the logs saying the import was successful? (it should show something)

you can always create a PR to my repo with your automation, or post it here and Iā€™ll update the readme :slight_smile:

I think you can use the power button already.
Argon one script is using pin 4 with pull down:

echo 'GPIO.setwarnings(False)' >> $powerbuttonscript
echo 'GPIO.setmode(GPIO.BCM)' >> $powerbuttonscript
echo 'shutdown_pin=4' >> $powerbuttonscript
echo 'GPIO.setup(shutdown_pin, GPIO.IN,  pull_up_down=GPIO.PUD_DOWN)' >> $powerbuttonscript

Please try adding this into config:

binary_sensor:
  - platform: rpi_gpio
    pull_mode: DOWN
    ports:
      4: Argon Power Button

ref: https://www.home-assistant.io/integrations/rpi_gpio/
maybe you will need to add invert_logic: true, but I canā€™t test that right now.

Iā€™ll try to add separate events for short and long press for that button, but first I need to enable I2C :slight_smile:

looking too for support about this case fan control capabilities. I installed your repo and enabled i2c, bit canā€™t find the argon40.set_fan_speed service in home assistant. What went wrong?

Hi, I was looking at the button too, had seen the argon script and already tried the binary sensor for pin 4, but for me it doesnt work, no response. invert_logic: true just makes the sensor appear always on in stead of always offā€¦ Wondering whether this does work for others?

@WillemH Iā€™ll test that and get back to you with detailed instruction.

Hmmm it might be because Iā€™m running HassOS on Rpi4, and from other forum threads it looks like that may be why gpio pins cant be read

I have the same config.
image

the problem is RPI.GPIO isnā€™ that good at reading updates of GPIO.
Iā€™ll try to write something, but not sure if Iā€™ll be able to change anything (Iā€™m also planning to use PRI.GPIO). I think gpiozero could be better, but canā€™t tell without trying :slight_smile:

I was able to detect double-tap.
code in my repo has that change. Please test if possible. If installing using HACS you must pick the master branch

automation:
  - alias: "Argon40 button double-tap"
    trigger:
      platform: event
      event_type: argon40_event
      event_data:
        action: double-tap
    action:
      - service: persistent_notification.create
        data:
          title: "Argon 40"
          message: "Button was double-tapped"

or