Skip to content

Instantly share code, notes, and snippets.

View splatch's full-sized avatar

Łukasz Dywicki splatch

View GitHub Profile
@splatch
splatch / LoginPage.jsx
Last active July 15, 2024 09:22
Example of use oidc-client-ts and react-oidc-context.
import {useAuth} from "react-oidc-context";
export default function LoginPage() {
const auth = useAuth();
return <>
<div style={{display: "flex", alignItems: 'center', justifyContent: 'center'}}>
<div style={{width: "25rem", display: "block", margin: "2rem"}}>
<h1>Web Energy Monitor</h1>
@splatch
splatch / MessageLog.jsx
Created June 4, 2024 16:53
Basic data table made with carbon and tanstack.
import {
DataTable,
Loading,
Tag, Toggletip, ToggletipButton, ToggletipContent, Layer
} from "@carbon/react";
import {Fragment} from "react";
import {useQuery} from "@tanstack/react-query";
import {Information} from "@carbon/icons-react";
const {
Bridge mqtt:broker:myInsecureBroker [ host="192.168.0.42", secure=false ]
Thing mqtt:topic:mything "mything" (mqtt:broker:myInsecureBroker) {
Channels:
Type switch : lamp "Kitchen Lamp" [ stateTopic="lamp/enabled", commandTopic="lamp/enabled/set" ]
Type switch : fancylamp "Fancy Lamp" [ stateTopic="fancy/lamp/state", commandTopic="fancy/lamp/command", on="i-am-on", off="i-am-off" ]
Type string : alarmpanel "Alarm system" [ stateTopic="alarm/panel/state", commandTopic="alarm/panel/set", allowedStates="ARMED_HOME,ARMED_AWAY,UNARMED" ]
Type color : lampcolor "Kitchen Lamp color" [ stateTopic="lamp/color", commandTopic="lamp/color/set", colorMode="RGB" ]
Type dimmer : blind "Blind" [ stateTopic="blind/state", commandTopic="blind/set", min=0, max=5, step=1 ]
}
<Things>
<things>
<things>
<kind>Thing</kind>
<UID>mqtt:topic:mything</UID>
<bridgeUID>mqtt:broker:myInsecureBroker</bridgeUID>
<label>mything</label>
<channels>
<id>lamp</id>
<type>switch</type>
things:
- kind: Bridge
thingTypeUID: mqtt:broker
id: myInsecureBroker
configuration:
host: "192.168.0.42"
secure: false
- kind: Thing
UID: mqtt:topic:mything
@splatch
splatch / page_overview.hbs
Created December 31, 2023 11:21
Example teamplate of overview page for openHAB made with handlebars.
basic: true
configurationPid: "cloud.connectorio.gateway.manaco.view.overview"
--
uid: overview
#tags: []
#props: []
component: oh-tabs-page
config:
visibleTo:
- role:administrator
2023-01-26T23:43:08.711Z INFO 1 --- [ault-executor-0] o.o.m.grpc.twin.AbstractTwinPublisher : Registered a session with key SessionKey{location='Default'}
2023-01-26T23:43:08.712Z INFO 1 --- [ault-executor-0] o.o.m.grpc.twin.AbstractTwinPublisher : Published an object update for the session with key SessionKey{location='Default'}
2023-01-26T23:43:11.879Z INFO 1 --- [ault-executor-0] o.o.m.grpc.twin.AbstractTwinPublisher : Registered a session with key SessionKey{location='Default1'}
2023-01-26T23:43:11.879Z INFO 1 --- [ault-executor-0] o.o.m.grpc.twin.AbstractTwinPublisher : Published an object update for the session with key SessionKey{location='Default1'}
2023-01-26T23:43:14.384Z INFO 1 --- [ault-executor-0] o.o.m.grpc.twin.AbstractTwinPublisher : Registered a session with key SessionKey{location='Default2'}
2023-01-26T23:43:14.384Z INFO 1 --- [ault-executor-0] o.o.m.grpc.twin.AbstractTwinPublisher : Published an object update for the session with key SessionKey{location='Default2'}
@splatch
splatch / gist:88dc8c9d3338c815c03ae145d3bb9c24
Created June 1, 2022 10:10
OData feed definition for Excel
# If you ever come to that point - official power query docs are not very clear
# on how to append custom headers or query options, here is how
= OData.Feed("https://....", null, [
Implementation="2.0",
Headers=[#"X-API-Token"="xyz",#"X-xyz"="zyx"],
Query=[#"timeZone"="UTC",#"another"="abc"]
])
@splatch
splatch / Main.java
Created April 19, 2021 17:30
Profinet DCP interaction based on experimental protocol implementation for Apache PLC4X.
import org.apache.plc4x.java.PlcDriverManager;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.messages.PlcSubscriptionEvent;
import org.apache.plc4x.java.utils.rawsockets.netty.RawSocketChannel;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
// Very simple example showing how to request profinet-dcp identification.
// Answers in line 23 are returned as PlcStruct (which is a map), for example:
@splatch
splatch / modbus.items
Created December 27, 2020 15:49
openHAB configuration for ineprometering PRO380-mod three phase meter.
String PRO380_ModbusId "Pro 380 Modbus id" { channel="modbus:data:pro380:metadata:serialNumber:number" }
Number PRO380_Voltage_L1 "Pro 380 L1 Voltage [%.2f]" { channel="modbus:data:pro380:voltage:L1:number" }
Number PRO380_Voltage_L2 "Pro 380 L2 Voltage [%.2f]" { channel="modbus:data:pro380:voltage:L2:number" }
Number PRO380_Voltage_L3 "Pro 380 L3 Voltage [%.2f]" { channel="modbus:data:pro380:voltage:L3:number" }
Number PRO380_Current_L1 "Pro 380 L1 Current [%.2f]" { channel="modbus:data:pro380:current:L1:number" }
Number PRO380_Current_L2 "Pro 380 L2 Current [%.2f]" { channel="modbus:data:pro380:current:L2:number" }
Number PRO380_Current_L3 "Pro 380 L3 Current [%.2f]" { channel="modbus:data:pro380:current:L3:number" }