Skip to content

Instantly share code, notes, and snippets.

View mew.yaml
- 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}}
View smieci_nr
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 Dec 17, 2020
postgraphile server
View index.js
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 Nov 29, 2020
postgraphile server
View index.js
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 Oct 1, 2020
Temp automation in NR
View nr.json
[
{
"id": "d8b80ebb.d6fee",
"type": "switch",
"z": "11f0e03c.ef0f",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
@pszafer
pszafer / no_source_select.gif
Last active Aug 28, 2020
lovelace not selecting source
View Esphome.yaml
esphome:
name: podlewanie8
platform: ESP32
board: mhetesp32minikit
wifi:
ssid: !secret wifi_ap
password: !secret wifi_pass
domain: !secret domain
@pszafer
pszafer / convert.py
Created Mar 26, 2020
AdrienCarState
View convert.py
#!/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:
View geojsonData.geojson
Loading
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 Apr 9, 2019
Notify 5 04/2019
View curl
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"