Re: zigbee2mqtt, anyone?

2023-12-27 Thread Zé Loff
On Wed, Dec 27, 2023 at 06:48:33PM +, Stuart Henderson wrote:
> On 2023/12/27 13:15, Zé Loff wrote:
> > On Wed, Dec 27, 2023 at 12:19:05PM +, Mikolaj Kucharski wrote:
> > > - Does anyone has work in progress zigbee2mqtt port?
> 
> I looked at it once, got as far as copying Makefile.template and
> realising that it uses node.js then stopped bothering.
> 
> It's possible to write ports for such software but it usually means
> fetching with npm and creating and uploading a tarball somewhere, then
> have the port fetch that tarball and extract/install to a sensible
> location. Ideally the npm/tarball stage should be in a Makefile target
> so it's easy for others to update it too.
> 
> > - change the ownership of /usr/local/opt/zigbee2mqtt/* to _zigbee2mqtt
> 
> It's a bad idea for the code to be writable by the uid running the
> service. Better if only the only writable files/dirs are those where
> data/logs/etc are stored.

Thanks for this, Stuart.  Like I said in my message, I didn't give the
whole thing too much thought, sadly.

For the record, only the "data" directory, and everything in it needs to
be owned by _zigbee2mqtt.

> > * Note that this suffers from the already described problem with node
> > ports, in that it won't start automatically on boot, but it will start
> > manually with "rcctl start".
> 
> Thanks to jca's knowledge of fiddly shell features, this should no
> longer be a problem in -current.


-- 
 



Re: zigbee2mqtt, anyone?

2023-12-27 Thread Stuart Henderson
On 2023/12/27 13:15, Zé Loff wrote:
> On Wed, Dec 27, 2023 at 12:19:05PM +, Mikolaj Kucharski wrote:
> > - Does anyone has work in progress zigbee2mqtt port?

I looked at it once, got as far as copying Makefile.template and
realising that it uses node.js then stopped bothering.

It's possible to write ports for such software but it usually means
fetching with npm and creating and uploading a tarball somewhere, then
have the port fetch that tarball and extract/install to a sensible
location. Ideally the npm/tarball stage should be in a Makefile target
so it's easy for others to update it too.

> - change the ownership of /usr/local/opt/zigbee2mqtt/* to _zigbee2mqtt

It's a bad idea for the code to be writable by the uid running the
service. Better if only the only writable files/dirs are those where
data/logs/etc are stored.

> * Note that this suffers from the already described problem with node
> ports, in that it won't start automatically on boot, but it will start
> manually with "rcctl start".

Thanks to jca's knowledge of fiddly shell features, this should no
longer be a problem in -current.



Re: zigbee2mqtt, anyone?

2023-12-27 Thread Zé Loff
On Wed, Dec 27, 2023 at 12:19:05PM +, Mikolaj Kucharski wrote:
> Hi.
> 
> - Does anyone has work in progress zigbee2mqtt port?

Not me.  I have no experience porting.

> - Does it make sense to try to use it on OpenBSD?

I do.  Whether it makes sense or not, is a different matter :)

> - Any hands on experience with zigbee2mqtt on OpenBSD?

Yes.  It works fine, AFAICT.  Here's what I did:

- pkg_add node

- added a _zigbee2mqtt user similar to other daemon users

- added this user to the 'dialer' group so that it can access the
  calling unit (e.g.  /dev/cuaU0). This can (and probably should, TBH)
  be avoided by changing the device's owner, either permanently or via
  hotplugd, but I didn't bother to.

- copied zigbee2mqtt into (a newly created) /usr/local/opt/zigbee2mqtt. 

- change the ownership of /usr/local/opt/zigbee2mqtt/* to _zigbee2mqtt

- created /etc/rc.d/zigbee2mqtt with the following contents:

#!/bin/ksh

daemon="/usr/local/bin/node"
daemon_flags="/usr/local/opt/zigbee2mqtt/index.js"
daemon_user=_zigbee2mqtt

. /etc/rc.d/rc.subr

pexp="$(eval echo ${daemon}${daemon_flags:+ ${daemon_flags}})"
rc_bg=YES
rc_reload=NO

rc_cmd $1

- rcctl enable zigbee2mqtt (* see note below)
- rcctl start  zigbee2mqtt

And that's it.

* Note that this suffers from the already described problem with node
ports, in that it won't start automatically on boot, but it will start
manually with "rcctl start".

> - If you are using it, are you happy, unhappy, gonna stick to it or not?

Have been using it for a while, and am happy with it.  Not so happy with
my setup, because it really should be properly installed/ported, but *I*
didn't bother to.  E.g. the 'data' directory is a mess, holding the
configuration files (should be in /etc), logs (/var/log), and the state
and database files (I'd put them somewhere in /var).

> I have zero experience with Zigbee or any home automation,
> that's why I am asking.
> 
> 
> -- 
> Regards,
>  Mikolaj
> 

-- 
 



zigbee2mqtt, anyone?

2023-12-27 Thread Mikolaj Kucharski
Hi.

- Does anyone has work in progress zigbee2mqtt port?

- Does it make sense to try to use it on OpenBSD?

- Any hands on experience with zigbee2mqtt on OpenBSD?

- If you are using it, are you happy, unhappy, gonna stick to it or not?

I have zero experience with Zigbee or any home automation,
that's why I am asking.


-- 
Regards,
 Mikolaj