misc/soliscloud-inverter-control#3: Control Server



Issue Information

Issue Type: issue
Status: closed
Reported By: btasker
Assigned To: btasker

Milestone: PoC
Created: 01-Jan-25 11:54



Description

Now that we've got the basic functionality, we need to build a small control server so that there's a HTTP endpoint for HomeAssistant to make calls to.

On the HomeAssistant end, the simplest way is probably to use the restful command integration - that'll expose a command as an action which can be called in automations.

The alternative is to have homeassistant call curl but I don't think it makes much sense to do that.



Toggle State Changes

Activity


assigned to @btasker

I know it's not supposed to be used for production, but my intention is to use the Flask debug server for this.

The reasons are

  • This setup is basically an example and should never ever be exposed to untrusted networks
  • The Flask debug server is single threaded and can only handle 1 request at a time. That's ideal for this, because we don't want concurrent requests hitting the soliscloud API
verified

mentioned in commit a97f39adf7ce53f028d086b78d2cd50150c1af25

Commit: a97f39adf7ce53f028d086b78d2cd50150c1af25 
Author: B Tasker                            
                            
Date: 2025-01-01T12:04:45.000+00:00 

Message

chore: start seting up for dockerised control server (misc/soliscloud-inverter-control#3)

+83 -1 (84 lines changed)
verified

mentioned in commit 86c87b344ade7c259ff00b824d654c4421925e65

Commit: 86c87b344ade7c259ff00b824d654c4421925e65 
Author: B Tasker                            
                            
Date: 2025-01-01T12:19:25.000+00:00 

Message

feat: create simple control api (misc/soliscloud-inverter-control#3)

+44 -10 (54 lines changed)

The server appears to work:

  • POST /api/v1/startCharge: Start charging
  • POST /api/v1/startDischarge: Start discharging
  • POST /api/v1/stopCharge: Stop a running charge (or discharge)
  • POST /api/v1/stopDischarge: Stop a running charge (or discharge)

None currently take any attributes.

Before we can consider this ticket done, though, I'd like to add support for basic authentication - given that the server talks direct to Soliscloud it'd probably be wise to make sure a crawler can't end up running commands.

verified

mentioned in commit ea27134f7108fa4809f39a34c443c8ccdc655e16

Commit: ea27134f7108fa4809f39a34c443c8ccdc655e16 
Author: B Tasker                            
                            
Date: 2025-01-01T12:40:05.000+00:00 

Message

feat: add authentication support (misc/soliscloud-inverter-control#3)

+44 -1 (45 lines changed)
verified

mentioned in commit a2bba7075e88a704aab3c7271e2f877605424f1b

Commit: a2bba7075e88a704aab3c7271e2f877605424f1b 
Author: B Tasker                            
                            
Date: 2025-01-01T12:42:46.000+00:00 

Message

feat: enable auth by default (misc/soliscloud-inverter-control#3)

+1 -0 (1 lines changed)

The server now has basic authentication support via a handful of env vars

# Is auth enabled
DO_AUTH=true

# Expected Username
USER=solisuser

# Password
PASS=supersecret

If PASS isn't provided a random one will be generated at server startup.

Auth is enabled by default - the default username is solisuser and the password will be randomly generated at startup (meaning it'll change whenever the container rolls and should be overridden)