Skip to content

Instantly share code, notes, and snippets.

@pszafer
pszafer / mew.yaml
Created October 8, 2021 13:52
mew01 filter
- name: "Energia MEW-01"
device_class: "energy"
unit_of_measurement: "kWh"
state_class: "total_increasing"
unique_id: mew_whatever
state: >
{% set energy = states('sensor.mew_01_mqtt') | float(default=-1) %}
{% set sens = states('sensor.mew_whatever') | float %}
{% if energy != -1 and sens <= energy %}
{{energy}}
const input = JSON.parse(msg.data.replace("eval(", "").replace(",],", "],").slice(0, -1));
const today = new Date()
const data_d = today.getDay();
const data_m = today.getMonth()+1;
const smieci = ["makulatura", "szklo", "zielone","kuchenne","resztkowe", "mix", "gabaryty" ]
const inputSortedByKind = input["dane"].reduce((acc, curr) => {
acc[curr["rodzaj"]].push(new Date(2021, +curr["data_m"]-1, +curr["data_d"]))
return acc
}, {
@pszafer
pszafer / index.js
Last active December 17, 2020 09:47
postgraphile server
import PgUpsertPlugin from "./PgUpsertPlugin";
import PostGraphileFulltextFilterPlugin from "./PostgraphileFullTextFilterPlugin"
import PgSimplifyInflectorPlugin from "@graphile-contrib/pg-simplify-inflector";
import ConnectionFilterPlugin from "postgraphile-plugin-connection-filter";
import PgOrderByRelatedPlugin from "@graphile-contrib/pg-order-by-related";
import PgOrderByMultiColumnIndexPlugin from "./PgOrderByMultiColumnIndexPlugin";
import { SHAREDTOKEN, CORS_OPTIONS, FORMTOKEN, hosts, adminPayload, workerPayload } from "../config";
import express from "express";
import UnauthorizedError from "./UnauthorizedError";
import { postgraphile, makePluginHook } from "postgraphile";
@pszafer
pszafer / index.js
Created November 29, 2020 10:14
postgraphile server
import PgUpsertPlugin from "./PgUpsertPlugin";
import PostGraphileFulltextFilterPlugin from "./PostgraphileFullTextFilterPlugin"
import PgSimplifyInflectorPlugin from "@graphile-contrib/pg-simplify-inflector";
import ConnectionFilterPlugin from "postgraphile-plugin-connection-filter";
import PgOrderByRelatedPlugin from "@graphile-contrib/pg-order-by-related";
import PgOrderByMultiColumnIndexPlugin from "./PgOrderByMultiColumnIndexPlugin";
import { SHAREDTOKEN, CORS_OPTIONS, FORMTOKEN, hosts, adminPayload, workerPayload } from "../config";
import express from "express";
import UnauthorizedError from "./UnauthorizedError";
import { postgraphile, makePluginHook } from "postgraphile";
@pszafer
pszafer / nr.json
Created October 1, 2020 11:16
Temp automation in NR
[
{
"id": "d8b80ebb.d6fee",
"type": "switch",
"z": "11f0e03c.ef0f",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
@pszafer
pszafer / no_source_select.gif
Last active August 28, 2020 16:43
lovelace not selecting source
Gif below
@pszafer
pszafer / Esphome.yaml
Created June 23, 2020 07:49
Water system
esphome:
name: podlewanie8
platform: ESP32
board: mhetesp32minikit
wifi:
ssid: !secret wifi_ap
password: !secret wifi_pass
domain: !secret domain
@pszafer
pszafer / convert.py
Created March 26, 2020 10:03
AdrienCarState
#!/bin/python3
import json
out={}
filename='testfile'
with open(f'{filename}.txt') as fin:
for line in fin:
x = line.rstrip().split("=")
out[x[0]] = x[1]
with open(f'{filename}.json', 'w') as fp:
@pszafer
pszafer / geojsonData.geojson
Created May 31, 2019 07:42
geojsonData.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pszafer
pszafer / curl
Last active April 9, 2019 15:52
Notify 5 04/2019
curl -X POST -H "Authorization:key=$key" -H "Content-Type: application/json" -d '{
"notification": {
"title": "This is custom title",
"body": "this is custom body",
"click_action": "https://google.com",
"data" : {"requireInteraction": true }
},
"registration_ids": ["$id"],
}' "https://fcm.googleapis.com/fcm/send"