What did you build/automated today (with pictures)?

I might get something better, if I need to do more of this. For this I just needed to solder two resistor networks in, and then I might have to solder something like that in a few years again… But this was just for fun to see if I could do it, there was plenty of space to just go with 0805 sized.

With just about 50 lines of code I created the mapping between my shelly roller shutters and the openhab proxy items.
The code

  • automatically creates the corresponding openhab rollershutter items
  • listens for the mqtt position event, inverts the percentage and posts an update to the openhab item
  • listens for commands from openhab, translates them to shelly commands and updates the mqtt topic so the shutter moves
  • also adds some small logging

If I add more shutters, I just have to add the device-id in the dict and everything else will happen automatically.

import logging
import re
import time
import typing

from HABApp import Rule
from HABApp.core.items import Item
from HABApp.openhab.events import ItemCommandEvent
from HABApp.mqtt.events import MqttValueChangeEvent

log = logging.getLogger('Rollladen')

class Rollladen(Rule):
    def __init__(self, name, device_id):
        super().__init__()
        
        self.name = name
        self.device_id = device_id
        
        # Set custom rule name so if something goes wrong we know where
        self.rule_name = f'Map{self.name}'
    
        self.mqtt_topic_position = f'shellies/shellyswitch25-{self.device_id}/roller/0/pos'
    
        self.run_soon(self.create_items)
        self.listen_event(self.name, self.command, ItemCommandEvent)
        self.listen_event(self.mqtt_topic_position, self.update_position, MqttValueChangeEvent)
    
    def create_items(self):
        # create openhab item
        if not self.openhab.item_exists(self.name):
            self.openhab.create_item(
                item_type='Rollershutter',
                item_name=self.name,
                # add label with spaces after each uppercase character and percent value
                label=re.sub( r"([A-Z])", r" \1", self.name).replace('ae', 'ä').replace('ue', 'ü') + ' [%d %%]',
                groups=['Rollladen']
            )
            
        # update position initially from cache
        self.update_position(self.get_item_state(self.mqtt_topic_position, 0))
    
    def command(self, event):
        assert isinstance(event, ItemCommandEvent), event
        
        target = {'UP': 'open', 'DOWN': 'close', 'STOP': 'stop'}.get(event.value, event.value)
        target = str(target)
        
        log.info( f'{self.name}: {target}')

        self.mqtt.publish(f'shellies/shellyswitch25-{self.device_id:s}/roller/0/command', target)
    
    def update_position(self, value_or_event):
        if isinstance(value_or_event, MqttValueChangeEvent):
            percent = value_or_event.value
        else:
            percent = value_or_event
        
        # assert and invert percentage
        assert isinstance(percent, (int, float)), type(percent)
        self.openhab.post_update(self.name, 100 - percent)
        
SHELLIES: typing.Dict[str, str] = {
    'RollladenZimmer1': 'BARCCA',
    'RollladenZimmer2': 'BARCDA'
    'RollladenZimmer3': 'BARCEA'
    'RollladenZimmer4': 'BARCFA'
}
    
# create all required rules
for name, value in SHELLIES.items():
    Rollladen(name, value)
3 Likes

I wrote a little python script to integrate the control of the apa102 rgb LEDs on a respeaker 2mic pi hat into openhab and Nodered over Mqtt.
Than I build a little box out of wood I had lying around and some old tights from my girlfriend :see_no_evil: which fits the respeaker and the pi zero w it’s attached too.
As I use Snips.ai for voice controlling openhab I can use this as a satellite for it but I can now also trigger the LEDs from Openhab over Mqtt to notify me about other things.
Here are some pictures


Johannes

1 Like

Hi Johannes,
how is your experience with the respeaker pi hat? Can it process what you say directly or how many tries do you need? Also at which distance?

Would be intersting as I might want to order one but it must work for the whole living room.

I didn’t know you could create items from Jython code! Thanks for this incredibly useful piece of knowledge! :star:

Whilst this is possible with Jython, too, I am running HABApp. It’s “real” Python, provides full syntax highlighting and the possibility to use any python lib with it. You can easily try it out from any machine since there is a config switch makes the connection to your openhab instance in read-only mode and thus will not change anything. Here’s the link to the documentation.

1 Like

It’s quite good up to 3m distance and in a fairly quiet environment. It is better than the Playstation eye cam but as it doesn’t have any audio pre processing it will still struggle with background noises.
If you have really big rooms I d recommend the respeaker mic array v2 (https://www.seeedstudio.com/ReSpeaker-Mic-Array-v2-0.html) as it has integrated audio processing and better far field capabilities.
But you can’t beat the price of the 2mic hat. I got mine for 8€ with shipping from China.
Johannes

Short and sweet post today:

WiFi + MQTT door chime! :slight_smile:

Hard do see the parts in the photo, here they are if you’re curious:



Plus inline fuse holder, wires. That’s all!
I’m driving the solid state relay directly from the RX pin on the ESP-01. I chose the RX pin because it’s the only I/O pin that does not go high during boot-up, which would have caused an unnecessary chime as you power it on.

I struggled for a while with a very small 3V mechanical relay driven by a transistor which was in turn controlled by the ESP-01… but it randomly rebooted sometimes when I controlled the relay. My oscilloscope showed me an insane amount of noise and oscillation on the supply line when I powered the relay. Power supply not liking the impedance change? Maybe. I gave up and went with a solid state relay (and got rid of the transistor too). Problem solved, works perfectly now!

2 Likes

A LED Aluminum Profile included in the ceiling and wall. With an Tunablewhite stripe, controlled by DMX Binding and KNX (self designed) switch (ZENNIO TMD Plus).

2 Likes

And another one :stuck_out_tongue_winking_eye:

1 Like

Cool switch! How do you use it?

Its a wired KNX Switch. You can use it with the KNX Binding

No, I mean there are 6 buttons on there. They look static, so what is the function of each button? I have a dozen buttons everywhere, if I get visitors, they are always lost :slight_smile:

Depends… it’s a Glas Switch. The 6 buttons have a LED behind it which indicates if it’s on or off. The pictures on the buttons shows the function. Main light, color led, roller shutter, music, …

Additionally you can configure a so called “welcome object”. F.e. to turn the light if you just hit the switch in the dark. And the switch has an input, where I added a motion sensor.
So my plan is a kind of “guest modus” option, where the lights just automatically turn on if it’s to dark.

Micro PV System

A few weeks ago I bought myself a micro PV system. It consists of two 275W panels and a matching micro inverter (EVT560). The panels are attached to a small stone wall on our terrace and are fed directly into the house grid for personal use.


The interesting thing is of course to know how much electricity is produced. That’s why I have routed the feed via a Sonoff POW to record the power every 30 seconds.


The right socket is used for feeding in, then goes into the Sonoff and from there into the left socket.

The Sonoff is flashed with the current Tasmota firmware and integrated into openHAB via MQTT. Grafana shows the current performance as a graphic.

Two topics are still open:

  1. Recording the used kWh .
  2. Currently a phase is being fed in. But my house electrics uses 3 phases. This means that I could always switch the solar system to the phase with the highest load in order to have the greatest benefit.

If someone has a complete set of rules, items etc. and other hints on the topic, I would be happy. :grinning:

Splendid!
I was already looking at this kind of lighting for a corrisor but couldn’t find the appropriate profiles…
Could you share the hardqare you used?
Also which KNX module works well with LED stripes and dimming?

I used Profiles vom IsoLicht.com: Midi 12mm for the ceiling. Good price value… I think.

I did not use a KNX module for dimming. I used an 24 Channel DMX Module. I needed a solution for a complete house. The DMX Modules have been much cheaper as KNX. The modules are placed inside a large switch cabinet with 24v Trafos and all other electronic stuff.

OpenHAB handles the translation between the KNX Switch and the 4 DMX modules with 24 channels each.

One risk in my set up: if openHAB is not running, the light Switches will not work. I am aware of that. But openHAB has been pretty reliable in past 7 years I was using it at my flat.

7 Likes

Thanks a lot for the details.
Concerning the KNX dimming there is now a fair priced (but not as cheap as the DMX you used) solution for constant current LEDs, the Meanwell LCM-40KNX. It was released in April and I found it just today…

Burglar Alarms are so boring…

I use Text to Voice over my Sonos speakers at full volume in each room. Scares the Bejasus out of me when it goes off and may be more effective than “Awooga! Awooga!”

Sadly, I can’t upload the .WAV file but it goes like this in Google’s pleasant female voice…

"Hello burglar. Nichola here. I hope you didn’t injure yourself breaking into my house.

You’ve triggered my alarm system, so I’ve contacted the ADT alarm monitoring company and they have notified the police. A patrol car is nearby and will arrive shortly.

I suggest you exit through the landing window, onto the garage roof as the front and back doors are deadlocked and will not open from the inside.

Better to turn your tail and run away and live to burgle another day, don’t you think?"

1 Like

Are you using a Google device that supports the Play & Say commands in DSL rules?

If so, you can put an MP3 file in the Sounds folder and use the Play command :slight_smile: (just put the filename into the play command, without a path, or you can use the PlayURL channel and use the full internal network address)

It’s how I play bespoke announcements :slight_smile: